【问题标题】:Closing Modal-dialog box after clicking "OK" in Vue.Js在Vue.Js中单击“确定”后关闭模态对话框
【发布时间】:2020-07-14 10:10:46
【问题描述】:

概述:在 Vue.js 中单击“确定”后,我试图关闭模式对话框。目前,它不会在单击“确定”时关闭,而是在单击“取消”、单击框外并按 ESC 键时关闭。 最后还给出了单击按钮后调用的方法。谢谢!

  <b-button-group class="mx-2" size="lg">
      <b-button
            @click="$bvModal.show('modal-1')"
            variant="light" class="border border-muted">
        <strong class="text-muted">Löschen  &raquo;</strong></b-button>
      <b-modal id="modal-1" title="Bitte bestätigen">
        <p class="my-4">Are you sure, you want to delete it?</p>
        <template v-slot:modal-footer="{ ok, cancel,}">
          
      <!-- Emulate built in modal footer ok and cancel button actions -->
      <b-button size="sm" variant="success" @click="okButtonClicked()" > OK </b-button>
      <b-button size="sm" variant="danger" @click="cancel()"> Cancel </b-button>
    </template>
      </b-modal>
    </b-button-group>

方法:{

    okButtonClicked: async function() { 
      let td_id =this.form.TransportDemandsId;
      console.log(this.form.TransportDemandsId);
      let url = "https://localhost:44370/api/transportdemand/abort/" + td_id;
      const res = await axios.delete(url);      
      let data = res.data;
      
      if (data === true) {
        alert("Response: OK. Transport Demand is Deleted: " );
      } else {
        alert("Response: Transport Demand not found");
      };
    }
  }
}

【问题讨论】:

    标签: javascript vue.js modal-dialog


    【解决方案1】:

    在您的方法 okButtonClicked 中缺少关闭功能。在方法okButtonClicked 中添加this.$bvModal.hide('modal-1'); 在要关闭模式的行中。可能在函数的末尾。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-09-14
      • 2011-12-16
      • 1970-01-01
      • 1970-01-01
      • 2011-08-18
      • 1970-01-01
      • 1970-01-01
      • 2020-03-02
      相关资源
      最近更新 更多