vue+elmentui的踩坑之路 (watch踩坑)
当需要监听对象的某一个属性的时候写法:data:{toEditForm: {id: null,functionType: null}},computed: {"toEditFormWfId": function(){return this.toEditFor...
·
当需要监听对象的某一个属性的时候写法:
data:{
toEditForm: {
id: null,
functionType: null
}
},
computed: {
"toEditFormWfId": function(){
return this.toEditForm.wfId
}
},
//同步职能分类名称
watch:{
"toEditFormWfId": function (val) {
// var that = this
const obj = this.workFunctionList.find((item) => item.id == val);
if( obj ){ //此判断非常重要
this.toEditForm.functionType = obj.functionType ;
}
}
}
判断重要的原因是: 如果没有此判断 ,当此页面再次刷新的时候,会报“functionType is undefined”的错误。
更多推荐
已为社区贡献4条内容
所有评论(0)