pushTarget和popTarget均为响应式所需的操作- 其中
handlers为数组的原因是因为,之前合并 options 的时候,放置在了一个数组里面,其中包含 mixin、extend 里的同一阶段的生命周期函数 $emit用于调用父组件挂载在当前组件上的生命周期回调函数,eg:@hook:beforeCreate="handleChildBeforeCreate"export function callHook (vm: Component, hook: string) {// #7573 disable dep collection when invoking lifecycle hookspushTarget()const handlers = vm.$options[hook]const info = `${hook} hook`if (handlers) {for (let i = 0, j = handlers.length; i < j; i++) {invokeWithErrorHandling(handlers[i], vm, null, vm, info)}}if (vm._hasHookEvent) {vm.$emit('hook:' + hook)}popTarget()}
