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