【问题标题】:Delete method with vue-tags-input Vue Js使用 vue-tags-input Vue Js 删除方法
【发布时间】:2019-12-09 07:26:35
【问题描述】:

我尝试在 Vue Js 的 vue-tags-input 中创建一个删除方法。我不确定如何获取索引。从这个标签。通常在我的删除方法中我使用索引。

<vue-tags-input
    v-model="tagName"
    class="tags-input w-100 mt-0"
    @before-deleting-tag="deleteCustomerName"
    />

deleteCustomerName: function () {
    const id = this.editedItemId;
    const id_c = 33;  //right now I am not sure how to get id_c 

    // const deleted_user_name = this.customer_names[index].name;
    this.boxOne = "";
    this.$bvModal
        .msgBoxConfirm("Are you sure that you want to delete this ?", {
            okVariant: "danger",
            okTitle: "Delete",
            cancelTitle: "Cancel",
            centered: true
        })
        .then(confirm => {
            if (confirm) {
                deleteApi("/customers/" + id + "/" + id_c).then(() => {
                    this.$nextTick(() => {
                        // this.$emit('deleted',deleted_user_name)
                        // this.customer_names.splice(index, 1);  //usualy I do this, but now it doesn't now how index is
                        console.log('User deleted!');
                    });
                });
            }

        })
        .catch(error => {
            console.log(error);
        });
},

【问题讨论】:

    标签: vue.js vuejs2


    【解决方案1】:

    这里描述的是http://www.vue-tags-input.com/#/api/events。 before-deleting-tag return index,tag,deleteTag[func] 所以你需要在deleteCustomerName参数范围内设置参数。

    deleteCustomerName: function (params) {
       console.log(params.index) 
       ....
    }
    

    【讨论】:

      猜你喜欢
      • 2020-11-04
      • 2019-11-16
      • 2019-06-19
      • 1970-01-01
      • 2021-04-08
      • 1970-01-01
      • 2023-03-27
      • 2020-10-23
      • 2016-10-06
      相关资源
      最近更新 更多