这个 this.timer 不需要再data里面定义
treeNodeproduct(data) {
if (this.timer) {
// 如果数据正在请求阻止并删除上次请求
clearTimeout(this.timer)
}
this.timer = setTimeout(() => {
// 接口请求数据 不用管这个判断 这是我自己写的一个判断
if ('departmentInfoVos' in data) {
this.projectList = []
} else {
this.categoryId = data.departmentId
this.$api.user.malist({ categoryId: data.departmentId, deptId: this.deptId }).then(res => {
if (res) {
this.projectList = res.rows
}
})
}
// 停下点击后多少秒后调用
}, 500)
},