watch使用了immediate之后,handler的this指向问题??
这里的handler方法不能使用箭头函数,改成传统function就可以了
list: {
handler: function (newList, oldList) {
this.handleListData(newList, oldList)
},
deep: true,
immediate: true
},
探讨Vue中watch使用immediate选项后,handler方法this指向问题。若遇到this指向不正确,应避免使用箭头函数,改用传统function解决,确保handleListData方法能正确访问。
这里的handler方法不能使用箭头函数,改成传统function就可以了
list: {
handler: function (newList, oldList) {
this.handleListData(newList, oldList)
},
deep: true,
immediate: true
},
1491
780
3990

被折叠的 条评论
为什么被折叠?