Reputation: 327
I'm trying access child ref from parent. I tried already in this ways:
1. PARENT
someMethod() {
console.log(this.$refs.someChildCompontentRef.$refs) // {}
}
CHILD
mounted(){
this.$emit('setRef', $this.refs.someRef);
}
PARENT
setRef(ref) {
console.log(ref) // undefinded don't know why?
}
Upvotes: 0
Views: 224
Reputation: 14914
My guess:
The virtual DOM is already builded up but the real DOM isnt. So you need to wait till its builded up:
async mounted(){
await this.$nextTick()
this.$emit('setRef', $this.refs.someRef);
}
Upvotes: 1