mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-05-22 06:31:45 +08:00
[new feature] Notify: add onOpened prop
This commit is contained in:
parent
333666f506
commit
5f5de381e8
@ -9,6 +9,7 @@
|
||||
##### Notify
|
||||
|
||||
- 新增`onClose`选项
|
||||
- 新增`onOpened`选项
|
||||
|
||||
##### Rate
|
||||
|
||||
|
@ -44,6 +44,9 @@ function Notify(
|
||||
onClick={(event: Event) => {
|
||||
emit(ctx, 'click', event);
|
||||
}}
|
||||
onOpened={() => {
|
||||
emit(ctx, 'opened');
|
||||
}}
|
||||
{...inherit(ctx)}
|
||||
>
|
||||
{props.message}
|
||||
|
@ -59,4 +59,5 @@ export default {
|
||||
| background | Background color | `String` | `#f44` |
|
||||
| className | Custom className | `String | Array | Object` | - |
|
||||
| onClick | Callback function after click | `Function` | - |
|
||||
| onOpened | Callback function after opened | `Function` | - |
|
||||
| onClose | Callback function after close | `Function` | - |
|
||||
|
@ -25,6 +25,11 @@ function Notify(options: NotifyOptions) {
|
||||
if (instance.onClick) {
|
||||
instance.onClick(event);
|
||||
}
|
||||
},
|
||||
opened() {
|
||||
if (instance.onOpened) {
|
||||
instance.onOpened();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -54,7 +59,8 @@ function defaultOptions(): NotifyOptions {
|
||||
duration: 3000,
|
||||
className: '',
|
||||
onClose: null,
|
||||
onClick: null
|
||||
onClick: null,
|
||||
onOpened: null
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -59,4 +59,5 @@ export default {
|
||||
| background | 背景颜色 | `String` | `#f44` | 1.4.7 |
|
||||
| className | 自定义类名 | `String | Array | Object` | - | 1.6.0 |
|
||||
| onClick | 点击时的回调函数 | `Function` | - | 2.0.0 |
|
||||
| onOpened | 完全展示后的回调函数 | `Function` | - | 2.0.0 |
|
||||
| onClose | 关闭时的回调函数 | `Function` | - | 2.0.0 |
|
||||
|
@ -28,7 +28,7 @@
|
||||
<van-password-input
|
||||
:value="value3"
|
||||
:mask="false"
|
||||
@focus="keyboard = 'value2'"
|
||||
@focus="keyboard = 'value3'"
|
||||
/>
|
||||
</demo-block>
|
||||
</demo-section>
|
||||
|
1
types/notify.d.ts
vendored
1
types/notify.d.ts
vendored
@ -10,6 +10,7 @@ export type NotifyOptions = {
|
||||
className?: any;
|
||||
background?: string;
|
||||
onClose?: (() => void) | null;
|
||||
onOpened?: (() => void) | null;
|
||||
onClick?: ((event: Event) => void) | null;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user