小编use*_*303的帖子

Vue JS 创建动态表格组件

我正在学习 Vue JS。我想创建一个组件来显示带有表格的数据,我可以在其他组件中重用它。我有 2 个道具项目(数据)和列(列名)

items: [
        {
            'id':'1',
            'title': 'hello',
            'description': 'ok ok',
            'created_date': '2018-09-09'
        },
        {
            'id':'2',
            'title': 'hello 2',
            'description': 'ok ok 2',
            'created_date': '2018-10-09'
        }
    ],
    columns: [ 'id', 'title', 'description', 'created_date']
Run Code Online (Sandbox Code Playgroud)

我想创建一个如下表

<table class="table">
<thead>
    <tr>
        <th v-for="(column, index) in columns" :key="index"> {{column}}</th>
    </tr>
</thead>
<tbody>
    <tr v-for="(item, index) in items" :key="index">
        <td v-for="(column, indexColumn) in columns" :key="indexColumn">{{item.$column}}</td>
    </tr>
</tbody>
Run Code Online (Sandbox Code Playgroud)

我不知道如何通过列名从项目中获取价值。是否可以创建这样的表?

html javascript vue.js

6
推荐指数
1
解决办法
1万
查看次数

IONIC 3中的setInterval

我想每1秒运行一次功能.搜索后,我发现setInterval但它对我不起作用.

setInterval(function(){ 
   this.myfuntion();

}, 1000);
Run Code Online (Sandbox Code Playgroud)

我也试过,this.myfuntion但它也不起作用.

javascript typescript ionic2 ionic3 angular

2
推荐指数
3
解决办法
1万
查看次数

标签 统计

javascript ×2

angular ×1

html ×1

ionic2 ×1

ionic3 ×1

typescript ×1

vue.js ×1