The onActivated hook accepts a second parameter of type ComponentInternalInstance, which makes it possible to use it outside the setup block, such as in custom directives. I noticed that the underlying implementation of the vue router's composition api is actually onUnmounted, onDeactivated, and onActivated, which can all specify the component instance by passing in the second parameter.
The
onActivatedhook accepts a second parameter of typeComponentInternalInstance, which makes it possible to use it outside the setup block, such as in custom directives. I noticed that the underlying implementation of the vue router's composition api is actuallyonUnmounted,onDeactivated, andonActivated, which can all specify the component instance by passing in the second parameter.