mirror of
https://gitee.com/vuejs/vue.git
synced 2024-12-05 05:27:59 +08:00
This reverts commit 4078ce9c58
.
This commit is contained in:
parent
eb601adb6d
commit
1bcc571739
@ -21,8 +21,6 @@ import {
|
|||||||
noop
|
noop
|
||||||
} from '../util/index'
|
} from '../util/index'
|
||||||
|
|
||||||
import BuiltinVue from '../index'
|
|
||||||
|
|
||||||
export function initState (vm: Component) {
|
export function initState (vm: Component) {
|
||||||
vm._watchers = []
|
vm._watchers = []
|
||||||
initProps(vm)
|
initProps(vm)
|
||||||
@ -145,16 +143,12 @@ function initMethods (vm: Component) {
|
|||||||
if (methods) {
|
if (methods) {
|
||||||
for (const key in methods) {
|
for (const key in methods) {
|
||||||
vm[key] = methods[key] == null ? noop : bind(methods[key], vm)
|
vm[key] = methods[key] == null ? noop : bind(methods[key], vm)
|
||||||
if (process.env.NODE_ENV !== 'production') {
|
if (process.env.NODE_ENV !== 'production' && methods[key] == null) {
|
||||||
methods[key] == null && warn(
|
warn(
|
||||||
`method "${key}" has an undefined value in the component definition. ` +
|
`method "${key}" has an undefined value in the component definition. ` +
|
||||||
`Did you reference the function correctly?`,
|
`Did you reference the function correctly?`,
|
||||||
vm
|
vm
|
||||||
)
|
)
|
||||||
hasOwn(BuiltinVue.prototype, key) && warn(
|
|
||||||
`Avoid overriding Vue's internal method "${key}".`,
|
|
||||||
vm
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,14 +24,4 @@ describe('Options methods', () => {
|
|||||||
})
|
})
|
||||||
expect(`method "hello" has an undefined value in the component definition`).toHaveBeenWarned()
|
expect(`method "hello" has an undefined value in the component definition`).toHaveBeenWarned()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should warn overriding builtin methods', () => {
|
|
||||||
new Vue({
|
|
||||||
methods: {
|
|
||||||
$emit () {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
expect(`Avoid overriding Vue's internal method "$emit".`).toHaveBeenWarned()
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user