Home  >  Article  >  Web Front-end  >  How to fill data into table in vue.js

How to fill data into table in vue.js

王林
王林Original
2021-10-12 16:16:253975browse

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 (...].

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:

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:


How to fill data into table in vue.js

Recommended learning:

php training

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn