core: custom directives on components: Can't access child component in directive hooks.
Version
3.0.2
Reproduction link
https://codesandbox.io/s/weathered-resonance-d2f6t?file=/src/App.vue
Steps to reproduce
import { createApp } from "vue";
const App = {
directives: {
mydir: {
mounted(el, binding, vnode, oldVnode) {
console.log(vnode.component) //vnode.component should be CompB vue instance, but now is null
}
}
},
render() {
return (<div>
<CompB name='a1' v-mydir="1" />
</div>)
}
}
let CompB = {
props: ['name'],
render() {
return (<div>{'test: ' this.name}</div>);
}
}
createApp(App).mount('#app');
What is expected?
vnode.component should be the CompB vue instance
What is actually happening?
vnode.component is null
About this issue
- Original URL
- State: open
- Created 6 years ago
- Reactions: 6
- Comments: 16 (3 by maintainers)
I figured out I can do
vnode.ctx.exposed.select()but that’s delving into private APIs which isn’t ideal.