watch: { // list 是存在vuex的 'list.a1': { handler: function (newData, oldData) { } }}vuex 的listlist:{// 初始时候并没有值,值是后面才加的}请问我该如何用 watch 监听这种前期不存在,后面才有的值呢?
2 回答
拉风的咖菲猫
TA贡献1995条经验 获得超2个赞
对整个list进行监听
computed: {
getList () {
return this.$store.state.list
}
}
watch: {
getList: {
handler: function (newData, oldData) {
console.log(newData.time, oldData.time)
// 处理
},
deep: true
}
}
添加回答
举报
0/150
提交
取消
