如何从B表中删除行

时间:2019-07-08 08:34:05

标签: javascript vue.js

嗨,我只是想问一下如何删除b表中的项目/行。我尝试通过@click.prevent="deleteCustomItem(data.data.item)发送项目 但是我不能使用Delete,因为我处于严格模式。

我的桌子:

 <custom-item-grid ref="customItemGrid" :is-busy="gridIsBusy" :key="invoice.id" :fields="gridItemsFields" :items="gridCustomItems">

    <template slot="action-buttons" slot-scope="data">
        <b-button v-b-tooltip.hover title="{{ __('Odstranit vlastní položku') }}" variant="danger" @click.prevent="deleteCustomItem(data.data.item)"><i class="fa fa-times"></i></b-button>
    </template>

</custom-item-grid>

deleteCustomItem

 deleteCustomItem(item) {
     console.log(item);
     this.showConfirmDialog('Delete', 'Are you sure?').then(value => {
         if (value === true) {

             //CODE HERE
         }
     });
 }

2 个答案:

答案 0 :(得分:0)

如果您将此 b表项目(如行)存储在Vue实例的某个数组中,然后使用v-for渲染了这些项目,则可以尝试使用{ {1}}在您的数组中,并使用.find()将其删除。如果不起作用,则可以获取节点的父节点并尝试使用.splice()

答案 1 :(得分:0)

这对我有用:

this.$delete(this.$refs.customItemGrid.items,item);
相关问题