問題描述:在某個頁面需打開一個Model,而後這個Model裏有一個Form表單,點擊肯定時我須要先校驗表單數據是否輸入正確,不肯定則不但願關閉窗口;(問題是:只要點擊確認 loading :false 狀況下iview默認就把this.visible = false 窗口就關閉了)iview
作法是:
Form校驗不經過,則:
this.$refs.model.visible = true;
這樣窗口就不會關閉;this
實例:spa
<template> <div> <Modal title="對話框" v-model="modal":maskClosable="false" :loading="modalLoading" @on-ok="ok" ref="modal"> <div class="ivu-modal-confirm-body" style="padding-left:0px;"> </div> </Modal> <button style="padding: 20px" @click="open">打開對話框</button> </div> </template> <script> export default { computed: { }, data() { return { modalLoading: true, modal: false, } }, methods:{ open(){ this.modal = true; }, ok () { if (1) { this.$refs.modal.visible = true; this.modalLoading = false;
this.open(); return } this.modal = false }, } } </script>