<van-dialog v-model="showDialog" @confirm="confirmFn" @cancel="showDialog = false" title="添加故障现象" show-cancel-button :before-close="onBeforeClose" > <div class="p10"> <van-field v-model="faultPhenomenon" placeholder="请输入" clearable :rules="[{ required: true, message: '请输入故障现象' }]" /> </div> </van-dialog>
onBeforeClose (action, done) { // 点击了确定按钮 if (action === "confirm") { if (this.faultPhenomenon == '') { this.$toast.fail('请输入故障现象'); return } // if()...也可以加入一些条件 return done(false);//直接return它即可阻止 } // 点击了取消按钮 else { done(true); //关闭弹窗, true可以省略 } }, // 确定添加故障现象 confirmFn () { },
标签:return,confirm,点击,done,dialog,van From: https://www.cnblogs.com/dianzan/p/18154421