mirror of
https://github.com/vuejs/vue.git
synced 2024-11-21 20:28:54 +00:00
parent
04b4703de7
commit
0825d3087f
@ -58,7 +58,7 @@ export function initMixin(Vue: typeof Component) {
|
||||
initLifecycle(vm)
|
||||
initEvents(vm)
|
||||
initRender(vm)
|
||||
callHook(vm, 'beforeCreate')
|
||||
callHook(vm, 'beforeCreate', undefined, false /* setContext */)
|
||||
initInjections(vm) // resolve injections before data/props
|
||||
initState(vm)
|
||||
initProvide(vm) // resolve provide after data/props
|
||||
|
@ -375,11 +375,16 @@ export function deactivateChildComponent(vm: Component, direct?: boolean) {
|
||||
}
|
||||
}
|
||||
|
||||
export function callHook(vm: Component, hook: string, args?: any[]) {
|
||||
export function callHook(
|
||||
vm: Component,
|
||||
hook: string,
|
||||
args?: any[],
|
||||
setContext = true
|
||||
) {
|
||||
// #7573 disable dep collection when invoking lifecycle hooks
|
||||
pushTarget()
|
||||
const prev = currentInstance
|
||||
setCurrentInstance(vm)
|
||||
setContext && setCurrentInstance(vm)
|
||||
const handlers = vm.$options[hook]
|
||||
const info = `${hook} hook`
|
||||
if (handlers) {
|
||||
@ -390,6 +395,6 @@ export function callHook(vm: Component, hook: string, args?: any[]) {
|
||||
if (vm._hasHookEvent) {
|
||||
vm.$emit('hook:' + hook)
|
||||
}
|
||||
setCurrentInstance(prev)
|
||||
setContext && setCurrentInstance(prev)
|
||||
popTarget()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user