Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[vue]生命周期 hook event #6

Open
siam-ese opened this issue Jan 4, 2021 · 0 comments
Open

[vue]生命周期 hook event #6

siam-ese opened this issue Jan 4, 2021 · 0 comments

Comments

@siam-ese
Copy link
Owner

siam-ese commented Jan 4, 2021

vue lifecycle hook event

可以对组件监听 hook:[lifecycle-name] 的事件,在 callhook 方法调用完成后,会传播事件

function callHook(vm, hook) {
  // #7573 disable dep collection when invoking lifecycle hooks
  pushTarget();
  var handlers = vm.$options[hook];
  var info = hook + ' hook';
  if (handlers) {
    for (var i = 0, j = handlers.length; i < j; i++) {
      invokeWithErrorHandling(handlers[i], vm, null, vm, info);
    }
  }
  if (vm._hasHookEvent) {
    vm.$emit('hook:' + hook);
  }
  popTarget();
}
@siam-ese siam-ese changed the title vue 生命周期 hook event [vue]生命周期 hook event Jan 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant