DrawerV2 抽屉
抽屉,只需关心弹窗内容。DrawerV2
组件的使用姿势与DialogV2
组件使用姿势几乎一致。
基础用法
triggerProps
对象类型是Partial<ButtonProps> & {triggerText?: string }
使用triggerProps
对象的triggerText
属性来快速设置触发器按钮的文案
取消、确定
cancelProps
对象类型是Partial<ButtonProps> & {hidden?: boolean; cancelText?: string}
sureProps
对象类型是Partial<ButtonProps> & {hidden?: boolean; sureText?: string}
使用这 2 个属性可以快速设置取消
和确定
按钮的文案及样式
按钮回调
onSure
和onCancel
回调函数的参数含有close
方法,用户可自行根据业务选择性调用
如果不设置这 2 个函数,点击后默认自动关闭弹窗
自定义触发器
有时需要完全自定义触发器 UI,这时紧靠triggerProps
设置ElButton
组件肯定满足不了,可以使用trigger
插槽来自定义
自定义的 ui 点击后默认冒泡,所以用户不必手动调用关闭弹窗的方法
自定义头部
可以使用header
插槽来自定义头部
该使用姿势和ElDrawer
一致
自定义底部
可以使用footer
插槽来自定义底部
该使用姿势和ElDrawer
一致
API
属性
弹窗其他相关的 API 属性,请参考 ElDrawer 即可,剩下是 DrawerV2
组件独有的 API 属性
属性名 | 说明 | 类型 | 默认值 |
---|---|---|---|
trigger-props | 触发按钮属性设置 | Object | - |
cancel-props | 取消按钮属性设置 | Object | - |
sure-props | 确定按钮属性设置 | Object | - |
on-cancel | 点击取消时的回调 | Function | - |
on-sure | 点击确定时的回调 | Function | - |
Slots
事件名 | 说明 |
---|---|
default | 对话框的默认内容 |
header | 对话框标题的内容 |
footer | 对话框底部的内容 |
trigger | 触发器插槽内容 |
Exposes
名称 | 详情 | 类型 |
---|---|---|
open | 打开弹窗 | Function |
close | 关闭弹窗 | Function |