vue改變循環(huán)遍歷后的數(shù)據(jù)實(shí)例
廢話不多說(shuō)了,直接上代碼吧!
<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:[],//定義列表數(shù)據(jù)信息
}
},
mounted(){
//獲取列表數(shù)據(jù)信息
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:{
//將狀態(tài)數(shù)字轉(zhuǎn)換為對(duì)應(yīng)的文字解釋
countTotal() {
for (let i = 0; i < this.tableDataList.length; i++) {
if (this.tableDataList[i].status === 0) {
this.tableDataList[i].status = '文字說(shuō)明0'
} else if (this.tableDataList[i].status === 1) {
this.tableDataList[i].status = '文字說(shuō)明1'
} else if (this.tableDataList[i].status === 2) {
this.tableDataList[i].status = '文字說(shuō)明2'
} else if (this.tableDataList[i].status === 3) {
this.tableDataList[i].status = '文字說(shuō)明3'
} else if (this.tableDataList[i].status === 4) {
this.tableDataList[i].status = '文字說(shuō)明4'
} else if (this.tableDataList[i].status === 5) {
this.tableDataList[i].status = '文字說(shuō)明5'
}
Vue.set(this.tableDataList,i,this.tableDataList[i])
}
}
}
}
</script>
注意:Vue.set(this.tableDataList,i,this.tableDataList[i]) 這段代碼必須寫(xiě),否則數(shù)據(jù)不會(huì)更新
以上這篇vue改變循環(huán)遍歷后的數(shù)據(jù)實(shí)例就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
effect返回runner單測(cè)實(shí)現(xiàn)示例詳解
這篇文章主要為大家介紹了effect返回runner單測(cè)實(shí)現(xiàn)示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-12-12
Vue?Router?實(shí)現(xiàn)登錄后跳轉(zhuǎn)到之前想要訪問(wèn)的頁(yè)面
這篇文章主要介紹了Vue?Router?實(shí)現(xiàn)登錄后跳轉(zhuǎn)到之前相要訪問(wèn)的頁(yè)面,本文僅演示路由跳轉(zhuǎn)和導(dǎo)航守衛(wèi)相關(guān)代碼的實(shí)現(xiàn),不包含具體的權(quán)限驗(yàn)證和登錄請(qǐng)求,需要的朋友可以參考下2022-12-12
Vue實(shí)現(xiàn)調(diào)用PC端攝像頭實(shí)時(shí)拍照
這篇文章主要為大家詳細(xì)介紹了Vue實(shí)現(xiàn)調(diào)用PC端攝像頭實(shí)時(shí)拍照,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-09-09
基于Vue實(shí)現(xiàn)文件上傳的幾種實(shí)現(xiàn)方式
文件上傳是web開(kāi)發(fā)中一個(gè)常見(jiàn)的需求,Vue.js作為一款流行的前端框架,也提供了方便的方法來(lái)實(shí)現(xiàn)文件上傳功能,下面這篇文章主要給大家介紹了關(guān)于基于Vue實(shí)現(xiàn)文件上傳的幾種實(shí)現(xiàn)方式,需要的朋友可以參考下2024-03-03
Vue this.$router.push(參數(shù))實(shí)現(xiàn)頁(yè)面跳轉(zhuǎn)操作
這篇文章主要介紹了Vue this.$router.push(參數(shù))實(shí)現(xiàn)頁(yè)面跳轉(zhuǎn)操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-09-09

