是否可以 $watch
Vue $refs
?
我想针对嵌套在我当前的Vue实例中但在 ready
回调中的子组件设置逻辑, $refs.childcomponent
最初是 undefined
在处理它时.
里面 ready()
this.$watch('$refs', function() {
console.log("not firing");
}, { deep: true });
结果:错误:超出最大调用堆栈
watch
实例的属性
watch: {
'$refs': {
handler: function() { console.log("hit"); },
deep: true
}
}
结果:什么都没有。
原文由 Kiee 发布,翻译遵循 CC BY-SA 4.0 许可协议
您可以
$watch
$refs.<name>.<data>
但不能$refs.<name>
本身,更不用说$refs
.https://jsfiddle.net/kenberkeley/9pn1uqam/