根据orderStatus改变span内的值
方法一:
<div v-for="(item,index) in allOrders" :key="index" class="orders-board">
<span>{{totalWords[index]}}</span>
<div>
data() {
return {
totalWords: []
};
},
computed: {
...mapState(['allOrders']),
},
mounted() {
this.createTotalWords();
},
methods: {
createTotalWords() {
const totalWords = this.allOrders.map(order => {
if (order.orderStatus === 'unPay') {
return '应付:';
}
return '合计:';
});
this.totalWords = totalWords;
},
}
方法二:
<div v-for="(item,index) in allOrders" :key="index" class="orders-board">
<span>{{totalWords[item.orderStatus]}}</span>
<div>
data() {
return {
totalWords: {
'unReceipt':'合计',
'unConsignment':'合计',
'unComment':'合计',
'unPay':'应付'
},
};
},
computed: {
...mapState(['allOrders']),
},
网友评论