Antd 的vue模态框modal去除确认或添加按钮(自定义按钮)

1.去除确认按钮

<template>
  <a-modal
    :title="title"
    :width="950"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @ok="handleOk"
    @cancel="handleCancel"
    cancelText="关闭">
	
    <template slot="footer">
      <a-button @click="handleCancel">关闭</a-button>
    </template>
	
  </a-modal>
</template>

这里的cancelText="关闭"是控制modal自带的按钮名字。
这个是只留下了关闭按钮,也可以换其他的,只留下确认按钮。
在这里插入图片描述
2.增加其他按钮

<template slot="footer">
  <a-button @click="handleCancel">取消</a-button>
  <a-button type="primary" @click="handleReject">驳回</a-button>
  <a-button type="primary" @click="handleOk">确定</a-button>
</template>

更换模态框内的template即可,可以看到这个是三个按钮的。
在这里插入图片描述

  • 10
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
### 回答1: 以下是实现一个对话框两个按钮的代码: ``` <template> <div> <a-button type="primary" @click="showModal"> 打开对话框 </a-button> <a-modal title="提示" :visible="visible" @ok="handleOk" @cancel="handleCancel" > <p>确定要执行此操作吗?</p> </a-modal> </div> </template> <script> import { Modal, Button } from 'ant-design-vue'; export default { components: { 'a-modal': Modal, 'a-button': Button, }, data() { return { visible: false, }; }, methods: { showModal() { this.visible = true; }, handleOk() { this.visible = false; // 执行确定操作 }, handleCancel() { this.visible = false; // 执行取消操作 }, }, }; </script> ``` ### 回答2: 在antd vue中实现一个对话框两个按钮的代码可以按照以下步骤进行: 1. 首先,确保已经安装了antd vuevue-router,并在项目中引入相应的组件。 2. 在需要使用对话框的组件中,引入antd vue的对话框组件和按钮组件。 3. 在data属性中定义一个布尔类型的变量来控制对话框的显示和隐藏,例如dialogVisible。 4. 在template标签中,使用对话框组件,并绑定dialogVisible变量来控制对话框的显示和隐藏。 ```html <template> <div> <a-button type="primary" @click="showDialog">打开对话框</a-button> <a-modal v-model="dialogVisible" title="对话框标题"> <span>对话框内容</span> <a-button @click="handleCancel">取消</a-button> <a-button type="primary" @click="handleOk">确定</a-button> </a-modal> </div> </template> ``` 5. 在methods属性中,定义showDialog方法来显示对话框,并将dialogVisible设置为true。 ```javascript methods: { showDialog() { this.dialogVisible = true; }, handleCancel() { this.dialogVisible = false; }, handleOk() { // 处理确定按钮的逻辑 } } ``` 通过以上代码,可以在antd vue中实现一个包含两个按钮的对话框。点击"打开对话框"按钮时,对话框将显示出来,用户可以点击"取消"按钮来关闭对话框,或点击"确定"按钮来执行相应的逻辑。 ### 回答3: 在 antd vue 中实现一个对话框需要使用 Modal 组件,并且结合 Button 组件来实现两个按钮。 代码示例: ```vue <template> <div> <Button type="primary" @click="showModal">显示对话框</Button> <Modal v-model="visible" title="对话框标题" @ok="handleOk" @cancel="handleCancel"> <p>对话框内容...</p> </Modal> </div> </template> <script> import { Modal, Button } from 'ant-design-vue'; export default { components: { Modal, Button, }, data() { return { visible: false, }; }, methods: { showModal() { this.visible = true; }, handleOk() { // 处理确认按钮点击事件 this.visible = false; }, handleCancel() { // 处理取消按钮点击事件 this.visible = false; }, }, }; </script> ``` 在这个示例中,我们使用了 antd vueModal 组件作为对话框,通过 `v-model` 绑定 `visible` 属性来控制对话框的显示与隐藏。在按钮点击事件中,我们通过修改 `visible` 属性的值来控制对话框的显示与隐藏。`@ok` 和 `@cancel` 分别绑定了点击确认按钮和取消按钮的事件处理方法,你可以根据具体需求在这两个方法中实现你想要的逻辑。
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值