vue中使用模态框传参_vue移动端模态框(可传参)的实现

本文介绍如何在Vue中封装一个模态框组件Mydialog,并详细阐述了两种使用方法:直接调用组件属性和使用对话框工具类dialogUtil。通过实例展示了如何在模态框中传递参数,包括标题、按钮文字等,简化了模态框的使用流程。
摘要由CSDN通过智能技术生成

1-封装模态框组件Mydialog (样式可以自己写)

export default {

props: {

visible: { type: Boolean, default: false },

options: {

type: Object,

default: {}

}

},

// 采用v-bind将visible传入

methods: {

ConfirmHandler () {

this.$emit('update:visible', false); // 更新visible的值(可选,如果想点击确认之后,进行一些处理再决定关不关闭,可取消在这里更新visible)

this.$emit('Confirm'); // 传递确认事件

},

CancelHandler () {

this.$emit('update:visible', false); // 更新visible的值

this.$emit('Cancel'); // 传递取消事件

},

close () {

this.visible = false;

}

},

/**

* modal 模态接口参数

* @param {string} modal.title 模态框标题

* @param {boolean} modal.showCancelButton 是否显示取消按钮

* @param {string} modal.cancelButtonClass 取消按钮样式

* @param {string} modal.cancelButtonText 取消按钮文字

* @param {string} modal.showConfirmButton 是否显示确定按钮

* @param {string} modal.confirmButtonClass 确定按钮样式

* @param {string} modal.confirmButtonText 确定按钮标文字

*/

computed: {

/**

* 格式化props进来的参数,对参数赋予默认值

*/

modal () {

let modal = this.options;

if (modal) {

modal = {

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值