VueJS $watch $refs
- 论坛
- VueJS $watch $refs
17 浏览
VueJS $watch $refs
是否可以使用Vue的$watch来监听$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
}
}
结果:无响应。