本文共 438 字,大约阅读时间需要 1 分钟。
需要使用到计算属性computed与监听watch
data中定义一个对象:
data(){ return{ obj:{ name:'xpf', gender:'male', age:24 } }}
computed中:将需要监听的参数放入一个新变量中
computed:{ 'newParams':function(){ const {name,age} = this.obj return {name,age} } },
watch中:监听新的变量
watch:{ newParams:function(){ alert(1) }},
完整代码:
watch同时监听多个属性 点我
转载地址:http://xrtgn.baihongyu.com/