vue.js挖坑记:屏蔽ivew的modal框确认按钮的关闭动作
问题:modal框作为表单验证,当表单内容通不过校验时,点击“确认”按钮希望不关闭modal框解决方案:关键一步操作 this.$nextTick(() => { this.loading = true; });<template><div><Button type="primary" @cl
·
问题:modal框作为表单验证,当表单内容通不过校验时,点击“确认”按钮希望不关闭modal框
解决方案:
关键一步操作 this.$nextTick(() => { this.loading = true; });
<template>
<div>
<Button type="primary" @click="modal1 = true">显示对话框</Button>
<Modal
v-model="modal1"
title="Modal"
@on-ok="ok"
:loading="loading">
<p>对话框内容</p>
<p>对话框内容</p>
<p>对话框内容</p>
</Modal>
</div>
</template>
<script>
export default {
data () {
return {
modal1: false,
loading: true
}
},
methods: {
ok () {
this.$Message.info('异步验证数据');
setTimeout(() => {
this.loading = false;
this.$nextTick(() => {
this.loading = true;
});
}, 1000);
}
}
}
</script>
更多推荐
已为社区贡献1条内容
所有评论(0)