let myData = [ {id:1,name:"小明",age:10,Career:null}, {id:2,name:"小抢",age:10,Career:"码农"}, {id:3,name:"小网",age:10,Career:null}, ];
要把Career为空的装换为字符串 - -
我的方式是
Nullzhuan(data){ if(data == null){ return "- -"; }else{ return data; } } let _this = this; myData.map(item=>{ item.name = _this.Nullzhuan(item.name); item.age= _this.Nullzhuan(item.age); item.Career = _this.Nullzhuan(item.Career); })
我感觉我这个太麻烦了,有什么什么更简单的方式呢?
MYYA
相关分类