我从后台拿到一段数据,是一段数组对象,格式如下:
[{name: 'a', state: 0}, {name: 'b', state: 1}, {name: 'c', state: 2}]
我需要在循环中判断它的state来给定不同的文字提示
例如:
0------就是办理中
1------就是已结办
2------就是已中止
我的代码如下:
<template>
<div
v-for="(item, index) in formatInfo"
:key="index"
class="result-progressBox">
<div class="result-progress">
<div class="result-progresstName">{{item.state}}</div>
</div>
</div>
</template>
<script>
export default {
data () {
return {
info: this.$store.state.IndexStore.Progress.cardSchedule //假设这里得到的格式就会上面的数组对象格式
}
}
computed: {
formatInfo () {
this.info.map((current, index) => {
switch (current.state) {
case '0': current.state = '办理中'
break
case '1': current.state = '已办结'
break
case '2': current.state = '已中止'
break
}
})
}
},
}
</script>
我这么写得不到我想要的效果,看不到‘办理中’等状态 只能渲染出来1 或者 0 或者 2### 问题描述
问题出现的环境背景及自己尝试过哪些方法
相关代码
// 请把代码文本粘贴到下方(请勿用图片代替代码)
这样不就行了吗