1.0.13 • Published 2 years ago

@iamgx/quick-el-drawer v1.0.13

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

quick el drawer

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

安装

npm i @iamgx/quick-el-drawer

使用

import ElQuickDrawer from '@iamgx/quick-el-drawer'

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

抽屉内容

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

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

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

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

配置

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

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

![Edit quick-el-drawer-example \(forked\)](https://codesandbox.io/static/img/play-codesandbox.svg)

其他工具

1.0.13

2 years ago

1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

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.5

2 years ago

1.0.4

2 years ago