1.0.16 • Published 2 years ago

@iamgx/quick-el-modal v1.0.16

Weekly downloads
-
License
-
Repository
github
Last release
2 years ago

quick el modal

在vuejs后台系统中, 经常使用到弹窗打开指定组件的操作, 每次要写一堆标签, 一堆状态控制, template显得非常臃肿, 我认为弹窗和弹窗内的业务逻辑应该是解耦的, 作为弹窗只负责展示组件, 业务都应该拆分出来 为了解决我开发中的这个痛点, 开发了快速创建弹窗的一个工具函数, 方便后台业务开发

安装

npm i @iamgx/quick-el-modal

使用

import ElQuickModal from '@iamgx/quick-el-modal'

// 简单用法
ElQuickModal({ title: '这是标题', component: '这是内容' })

弹窗内容

// 使用render函数渲染自定义组件
ElQuickModal({  title: '这是标题', component: h => h('h1', '这是内容') })

// 渲染import组件
import Example from 'path/to/example.vue'
ElQuickModal({  title: '这是标题', component: Example })

ElQuickModal({  title: '这是标题', component: require( 'path/to/example.vue').default })

// 渲染vue组件对象
const CusomComponent = { name: 'CustomCom', render: h => h('el-button', 'el button!') }
ElQuickModal({ title: '这是标题',  component: CusomComponent })

配置

  • 参数传递时使用驼峰写法
参数说明类型默认值
titleModal 的标题string-
componentDialog显示的内容string/VNode/h函数Null
propscomponent渲染组件的时候透传给组件的参数object{}
on渲染组件内部派发的事件, 通过on接收object{}
widthModal 的宽度string50%
fullscreen是否为全屏 Dialogbooleanfalse
modal是否需要遮罩层booleantrue
modal-append-to-body遮罩层是否插入至 body 元素上,若为 false,则遮罩层会插入至 Dialog 的父元素上booleantrue
append-to-bodyDialog 自身是否插入至 body 元素上。嵌套的 Dialog 必须指定该属性并赋值为 truebooleanfalse
custom-classDialog 的自定义类名string-
center是否对头部和底部采用居中布局booleanfalse
show-close是否显示关闭图标booleantrue
animation切换全屏的时候是否需要动画booleanfalse
buttonsDialog的按钮, 为空时不显示footerarray: {text, callback, name, confirm}[]
buttonLoadingKeys需要loading的按钮的name值array[]
buttonDisabledKeys需要禁用的按钮的name值array[]
showCancelButton是否显示取消按钮booleanfalse

live demo(结合一个打开表单并提交到后台然后关闭弹窗的一个业务场景)

Edit quickel-modal-example (forked)

其他工具

1.0.16

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.12

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago