Vue之循環遍歷Json數據,填充Table表格


簡單記一次Vue循環遍歷Json數據,然后填充到Table表格中,展示到前端的代碼:

1 async getData(id) {
2     const res = await this.$store.api.newReq('/xxx/xxx/xxx/' + id).get();
3     if (res.code === 0) {
4 
5         this.data = res.data;
6     }
7 },

下面是定義變量:

1 data: {
2     base: {},
3     baseList:[],
4 },

下面是table的表格展示:

 1 <table class="el-table el-table--fit el-table--border table-detail">
 2     <thead>
 3         <tr>
 4             <th>ID</th>
 5             <th>文章id</th>
 6             <th>分類名稱</th>
 7             <th>分類等級</th>
 8             <th>創建時間</th>
 9         </tr>
10     </thead>
11     <tbody>
12         <tr v-for="cm in  data.categoryMapList">
13             <td v-text="cm.id"></td>
14             <td v-text="cm.docId"></td>
15             <td v-text="cm.categoryName"></td>
16             <td v-text="cm.categoryLevel"></td>
17             <td v-text="cm.createTime"></td>
18         </tr>
19     </tbody>
20 </table>

效果圖:

打完收工!

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM