iview中模态窗、弹出框(Modal)的确认和取消按钮问题

在使用iview做后台管理的过程中,遇到一个情况,我需要在弹出框点击确认按钮的时候,判断数据填写是否完整,但是自带的on-ok方法会取消显示弹出框,自己写样式的话怕兼容性不好,查了官网上的属性后,使用slot插槽,把两个按钮放在弹出框底部,Modal双向绑定一个变量,直接写方法绑定,在ok的方法中可以控制弹出框是否显示

template
 <Modal v-model="modal" title="选择优质会员" width="1000">
		<!-- 搜索 -->
		<Input v-model="content" placeholder="请输入昵称" />
		<Button @click="handleSearch" type="primary">搜索</Button>
		<!-- 模态窗底部 -->
		<div slot="footer">
		  <Button type="default" @click="cancel">取消</Button>
		  <Button type="primary" @click="ok">确认</Button>
		</div>
</Modal>
js
export default {
data(){
  return{
    modal:false
  }
},
methods:{
  ok(){
    this.modal=true
    }
  cancel(){
    this.modal=false
    }
  }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值