vue.js遍歷二維數(shù)組的方法:【<table cellpadding="0" cellspacing="0" class="clearfix bigTable" id='downloaddata'><tr v-for='(ite…】。
本文操作環(huán)境:windows10系統(tǒng)、vue.js 2.9、thinkpad t480電腦。
在vue中我們可以使用v-for遍歷二維數(shù)組,具體實(shí)現(xiàn)代碼如下所示:
<table cellpadding="0" cellspacing="0" class="clearfix bigTable" id='downloaddata'> <tr v-for='(item, index) in data'> <template v-for='items in item'> <template v-for='(itemss, indexs) in items' v-if='indexs !== "type"'> <td>{{itemss}}</td> </template> </template> </tr>
其中,data數(shù)據(jù)為:
this.data = [ [ { type: '', name: '資產(chǎn)', start: '期末余額', end: '期初余額' }, { type: '', name: '負(fù)債和所有者權(quán)益(或股東權(quán)益)', start: '期末余額', end: '期初余額' } ], [ { type: '', name: '資產(chǎn)', start: 125000, end: 12534567 }, { type: '', name: '負(fù)債', start: 125000, end: 12534567 } ], [ { type: '資產(chǎn)', name: '貨幣資金', start: 125000, end: 12534567 }, { type: '負(fù)債', name: '應(yīng)付短期融資款', start: 125000, end: 12534567 } ], [ { type: '資產(chǎn)', name: '其中:客戶存款', start: 125000, end: 12534567 }, { type: '', name: '所有者權(quán)益(或股東權(quán)益)', start: 125000, end: 12534567 } ], [ { type: '資產(chǎn)', name: '', start: '', end: '' }, { type: '所有者權(quán)益(或股東權(quán)益', name: '實(shí)收資本(或股本)', start: 125000, end: 12534567 } ], [ { type: '資產(chǎn)', name: '資產(chǎn)總計(jì)', start: 111, end: 11 }, { type: '所有者權(quán)益(或股東權(quán)益', name: '資本公積', start: 125000, end: 12534567 } ] ]
結(jié)果:
推薦學(xué)習(xí):php培訓(xùn)