废话不多说了,直接上代码吧!
<dd class="clearfix" v-for="(item,index) in tableDataList" :class="index%2 != 0 ? 'dd-bg' : ''">
<div class="indexItem indexItem3 tal" title=""><span>{{item.status}}{{countTotal}}</span></div>
</dd>
<script type="text/ecmascript-6">
import Vue from 'vue'
import axios from 'axios'
export default {
data(){
return{
tableDataList:[],//定义列表数据信息
}
},
mounted(){
//获取列表数据信息
axios.get('url',{
withCredentials: true
})
.then((res) => {
// console.log(res);
let tableData = res.data.data;
this.tableDataList = tableData.table_list;
})
.catch((error) => {
console.log(error)
})
},
computed:{
//将状态数字转换为对应的文字解释
countTotal() {
for (let i = 0; i < this.tableDataList.length; i++) {
if (this.tableDataList[i].status === 0) {
this.tableDataList[i].status = '文字说明0'
} else if (this.tableDataList[i].status === 1) {
this.tableDataList[i].status = '文字说明1'
} else if (this.tableDataList[i].status === 2) {
this.tableDataList[i].status = '文字说明2'
} else if (this.tableDataList[i].status === 3) {
this.tableDataList[i].status = '文字说明3'
} else if (this.tableDataList[i].status === 4) {
this.tableDataList[i].status = '文字说明4'
} else if (this.tableDataList[i].status === 5) {
this.tableDataList[i].status = '文字说明5'
}
Vue.set(this.tableDataList,i,this.tableDataList[i])
}
}
}
}
</script>
注意:Vue.set(this.tableDataList,i,this.tableDataList[i]) 这段代码必须写,否则数据不会更新
以上这篇vue改变循环遍历后的数据实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持亿速云。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。