如何将下面的js版的watch,改成ts版:
watch: {
checkVal: {
handler: function (val) {
if (val) {
this.checkList.forEach((item) => {
this.checkVal.forEach((i) => {
if (i == item[this.idKey]) {
this.checkRightList.push(item);
}
});
});
const res = new Map();
this.checkRightList = this.checkRightList.filter(
(a) => !res.has(a[this.idKey]) && res.set(a[this.idKey], 1)
);
}
},
deep: true,
},
showList: {
handler: function (val) {
if (val) {
this.$emit('change', val);
}
},
deep: true,
},
},
可以看看这篇文章: https://github.com/kaorun343/vue-property-decorator