Vue.js 如何删除vue表中的整个列?

Vue.js 如何删除vue表中的整个列?,vue.js,vuejs2,vue-tables-2,Vue.js,Vuejs2,Vue Tables 2,我在删除vue表中的整列及其对应行时遇到问题。 这是我的密码 <b-table :fields="fields" :items="data"> <template slot="action" slot-scope="data" v-if="authorize = 1"> </template> </b-table> exp

我在删除vue表中的整列及其对应行时遇到问题。 这是我的密码

<b-table :fields="fields" :items="data">

    <template slot="action" slot-scope="data" v-if="authorize = 1">

    </template>

</b-table>



export default{
    data(){
       authorize: 0,
       data: [],
       fields: [
          {key: 'id', label: '#'},
          {key: 'name', label: 'Name'},
          {key: 'action', label: 'Action'}
        ],
   }
}
我的问题是,我想像这样删除列本身

| # | Name                   |
------------------------------
| 1 | John Doe               | 
| 2 | Chicharon Ni Mang Juan | 
| 3 | Lumanog                | 

#关于,

对于vue-tables-2,我认为除了为不同的列集设置条件外,没有其他选择,如在计算中。例如:

computed: {
 fields: function() {
  let fields = [{key: 'id', label: '#'}, {key: 'name', label: 'Name'}]
  if (this.authorize === 1) {
    fields.push({key: 'action', label: 'Action'})
  }
  return fields
 }
}

我只是找到了一个简单的解决方案,不以这种方式使用表格:

<b-table :fields="fields" :items="data">
     <template slot="action" slot-scope="data" v-if="authorize = 1">
      </template>
</b-table>

我刚刚使用了这个简单的html表:

<table class="table" style="width:100%">
    <thead>
        <tr>
            <th>#</th>
            <th>Name</th>
            <th v-if="authorize == 1">Action</th>
        </tr>
    </thead>
    <tbody>
        <tr v-for="user in data">
            <td>{{ user.id }}</td>
            <td>{{ user.name }}</td>
            <td v-if="authorize == 1">
                 <button variant="primary">Delete</button>
            </td>
        </tr>
    </tbody>
</table>

#
名称
行动
{{user.id}
{{user.name}
删除
在这里,我可以轻松地操作以删除/显示列及其数据


谢谢您应该使用
v-for
,以便更轻松地操作html元素。
<table class="table" style="width:100%">
    <thead>
        <tr>
            <th>#</th>
            <th>Name</th>
            <th v-if="authorize == 1">Action</th>
        </tr>
    </thead>
    <tbody>
        <tr v-for="user in data">
            <td>{{ user.id }}</td>
            <td>{{ user.name }}</td>
            <td v-if="authorize == 1">
                 <button variant="primary">Delete</button>
            </td>
        </tr>
    </tbody>
</table>