我需要在传入子组件某个字更新后,将子组件重新渲染,打算使用:key值更新
结果发现 子组件发现 watch chatWindowData.id 不触发
<chat-window-interface :key="chatWindowData.id"
:landlordAndTenant.sync="landlordAndTenant"
:chatWindowData.sync="chatWindowData"></chat-window-interface>
// 打开聊天窗口
openChatWindow(_item) {
this.chatWindowData = _item
},
子组件 watch不触发
watch: {
'chatWindowData.id': {
deep: true,
handler() {
console.log('watch')
this.chatInit()
}
}
}
你改变了
:key
, watch 中的值又没有变化,那怎么触发?