vue 提示框modal_ant design vue Modal 对话框和表单的使用

本文详细介绍了如何在Vue项目中使用ant design vue的Modal组件进行对话框操作,包括基本的模态框显示、确认和取消按钮自定义、对话框与表单的结合使用。通过实例展示了两种不同的表单绑定方式,以及表单验证和处理表单值的注意事项,如使用$nextTick避免渲染问题和设置初始值。同时,还提及了ant design vue中FormModel表单的使用方法和表单验证规则。
摘要由CSDN通过智能技术生成

对话框基本使用

显示模态框

title="模态框标题"

:visible="visible"

:confirm-loading="confirmLoading"

@ok="handleOk"

@cancel="handleCancel"

>

{ { ModalText }}

export default {

data() {

return {

ModalText: 'Content of the modal',

visible: false,

confirmLoading: false,

};

},

methods: {

//显示模态框

showModal() {

this.visible = true;

},

//点击ok

handleOk(e) {

this.ModalText = 'The modal will be closed after two seconds';

this.confirmLoading = true;

setTimeout(() => {

this.visible = false;

this.confirmLoading = false;

}, 2000);

},

//点击cancel

handleCancel(e) {

console.log('Clicked cancel button');

this.visible = false;

},

},

};

效果

设置对话框确认和取消按钮的文字

ok-text : 设置确认按钮文字

cancel-text : 设置取消按钮文字

例:

title="模态框标题"

ok-text="确认"

cancel-text="取消"

:visible="visible"

:confirm-loading="confirmLoading"

@ok="handleOk"

@cancel="handleCancel"

>

效果

对话框结合form表单使用

方式1:自定义组件模板的方式

显示模态框

ref="collectionForm"

:visible="visible"

@cancel="handleCancel"

@create="handleCreate"

/>

const CollectionCreateForm = {

props: ['visible'],

beforeCreate() {

this.form = this.$form.createForm(this, { name: 'form_in_modal' });

},

template: `

:visible="visible"

title='模态框标题'

okText='确认'

cancel-text="取消"

@cancel="() => { $emit('cancel') }"

@ok="() => { $emit('create') }"

>

v-decorator="[

'title',</

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值