Skip to content

Commit 7917833

Browse files
committed
feat: add custom handle
1 parent 995469e commit 7917833

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

components/drawer/index.en-US.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
| height | placement is `top` or `bottom`, height of the Drawer dialog. | string\|number | - |
1717
| zIndex | The `z-index` of the Drawer. | Number | 1000 |
1818
| placement | The placement of the Drawer. | 'top' \| 'right' \| 'bottom' \| 'left' | 'right' |
19+
| handle | After setting, the drawer is directly mounted on the DOM, and you can control the drawer to open or close through this `handle`. | VNode \| slot | - |
1920

2021

2122
## Methods

components/drawer/index.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const Drawer = {
2424
placement: PropTypes.oneOf(['top', 'right', 'bottom', 'left']).def('right'),
2525
level: PropTypes.any.def(null),
2626
wrapClassName: PropTypes.string, // not use class like react, vue will add class to root dom
27+
handle: PropTypes.any,
2728
},
2829
mixins: [BaseMixin],
2930
data() {
@@ -181,10 +182,11 @@ const Drawer = {
181182
} else {
182183
offsetStyle.height = typeof height === 'number' ? `${height}px` : height;
183184
}
185+
const handler = getComponentFromProp(this, 'handle') || false;
184186
const vcDrawerProps = {
185187
props: {
186-
handler: false,
187188
...rest,
189+
handler,
188190
...offsetStyle,
189191
open: visible,
190192
showMask: props.mask,

components/drawer/index.zh-CN.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
| width | 宽度 | string \| number | 256 |
1616
| height | 高度, 在 `placement``top``bottom` 时使用 | string \| number | 256 |
1717
| zIndex | 设置 Drawer 的 `z-index` | Number | 1000 |
18-
| placement | 抽屉的方向 | 'top' \| 'right' \| 'bottom' \| 'left' | 'right'
18+
| placement | 抽屉的方向 | 'top' \| 'right' \| 'bottom' \| 'left' | 'right'|
19+
| handle | 设置后抽屉直接挂载到DOM上,你可以通过该handle控制抽屉打开关闭 | VNode \| slot | - |
1920

2021
## 方法
2122

components/vc-drawer/src/Drawer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,8 +408,8 @@ const Drawer = {
408408
<i class="drawer-handle-icon" />
409409
</div>
410410
);
411-
const { handler: handlerSlot } = this.$slots;
412-
const handlerSlotVnode = handlerSlot || handlerDefalut;
411+
const { handler: handlerSlot } = this;
412+
const handlerSlotVnode = (handlerSlot && handlerSlot[0]) || handlerDefalut;
413413
const { click: handleIconClick } = getEvents(handlerSlotVnode);
414414
handlerChildren = cloneElement(handlerSlotVnode, {
415415
on: {

0 commit comments

Comments
 (0)