在写项目时,遇到表格如果有空数据,显示‘--’的需求:

1.png
export default {
data() {
return {
uuid:'',
datas:[],
}
},
mounted: function () {
this.uuid = getStore('uuidTest').aa;
this.get_market();
},
methods: {
get_market(){
this.$axios.get('/website/websiteClient/queryMarket/?wareKindid='+this.tradeType,
{
headers: {
'UUID': this.uuid
}
}
)
.then(res => {
if(res.data.code == 0){
if(res.data.data.length !== 0){
this.showA = false;
res.data.data.forEach((item) => {
if(item.NEWPRICE == 0.00 || item.NEWPRICE == ''){
item.NEWPRICE= '--';
}
if(item.HIGHPRICE == 0.00 || item.HIGHPRICE == ''){
item.HIGHPRICE= '--';
}
if(item.LOWPRICE == 0.00 || item.LOWPRICE == ''){
item.LOWPRICE= '--';
}
if(item.BUYPRICE1 == 0.00 || item.BUYPRICE1 == ''){
item.BUYPRICE1= '--';
}
if(item.SALPRICE1 == 0.00 || item.SALPRICE1 == ''){
item.SALPRICE1= '--';
}
});
this.datas = res.data.data;
}
}
})
}
},
