Home >Web Front-end >Vue.js >How to fill data into table in vue.js
##The operating environment of this article: windows10 system, vue.js 2.9, thinkpad t480 computer. Use vue to loop through the Json data, and then fill the data into the Table table. Display code:Vue.js method of filling data into the table: [async getData(id) {const res = await this.$store.api.newReq('/xxx/xxx/xxx/' id).get ();if (...].
async getData(id) { const res = await this.$store.api.newReq('/xxx/xxx/xxx/' + id).get(); if (res.code === 0) { this.data = res.data; } },Define variables:
data: { base: {}, baseList:[], },table table display:
<table class="el-table el-table--fit el-table--border table-detail"> <thead> <tr> <th>ID</th> <th>文章id</th> <th>分类名称</th> <th>分类等级</th> <th>创建时间</th> </tr> </thead> <tbody> <tr v-for="cm in data.categoryMapList"> <td v-text="cm.id"></td> <td v-text="cm.docId"></td> <td v-text="cm.categoryName"></td> <td v-text="cm.categoryLevel"></td> <td v-text="cm.createTime"></td> </tr> </tbody> </table>The renderings are as follows:
The above is the detailed content of How to fill data into table in vue.js. For more information, please follow other related articles on the PHP Chinese website!