我是 vue.js 新手。这是我用铅笔写的
<i
class="mdi mdi-pencil"
@click.prevent="$bvModal.show(type.title)"
></i>
这适用于模态
<b-modal
:id="type.title"
ref="modal"
title="Update holiday"
centered
hide-footer
>
<FormModal
cardTitle="Update holiday"
description=""
:value="type.title"
action="update"
@formData="parseFormData"
:holidayTypeID="type.id"
></FormModal>
这就是函数
holidaysTypeUpdate(value, holidayID) {
this.$refs["modal"][0].hide();
session
.put(`api/holidays/holiday-type/${holidayID}/action/`, {
title: value,
})
.then(() => {
this.alertSchema = {
alertVariant: "success",
alertMsg: "Holiday updated",
show: true,
};
this.$bvModal.hide("type.title");
this.fetchHolidayTypes();
})
.catch((e) => {
console.log(e.response.data);
});
},
当我按下按钮时,数据会更新,但模式不会关闭。当我更新数据时,我该怎么做才能关闭模式?
现在我试试这个
holidaysTypeUpdate(value, holidayID) {
console.log("holiday is", holidayID, value);
this.$bvModal.hide(value);
session
.put(`api/holidays/holiday-type/${holidayID}/action/`, {
title: value,
})
.then(() => {
this.alertSchema = {
alertVariant: "success",
alertMsg: "Ο τύπος Αδειας ανανεώθηκε",
show: true,
};
this.$bvModal.hide('type.title');
this.fetchHolidayTypes();
})
.catch((e) => {
console.log(e.response.data);
});
},
但是当我不更改某些内容并按更新时,模式会关闭,但是当我更改某些内容并按更新时,模式不会关闭。