如图所示,我们一般监听一个变量的时候,都是写死的,如上图的flag 变量,如何动态监听一个属性呢?比如 this.$watch(flag,(newVal)=>{console.log('我监听到了')})
已解决 this.$watch('student.count', function (newValue, oldValue) {//a是属性名,表示要监听的对象debugger})