问题:父组件向子组件传值,并且在父组件中动态改变传递的值,发现子组件不能动态响应
只需要在子组件中监听需要响应的字段
dataName是需要监听的数据字段
props: {
dataName: String
},
deep: true 代表深度监听
watch: {
dataName: {
handler(newValue, oldValue) {
this.oldValue = newValue;
},
deep: true
}
}
Comments | NOTHING