[new feature] Notify: add onOpened prop

This commit is contained in:
陈嘉涵 2019-05-30 14:29:59 +08:00
parent 333666f506
commit 5f5de381e8
7 changed files with 15 additions and 2 deletions

View File

@ -9,6 +9,7 @@
##### Notify
- 新增`onClose`选项
- 新增`onOpened`选项
##### Rate

View File

@ -44,6 +44,9 @@ function Notify(
onClick={(event: Event) => {
emit(ctx, 'click', event);
}}
onOpened={() => {
emit(ctx, 'opened');
}}
{...inherit(ctx)}
>
{props.message}

View File

@ -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` | - |

View File

@ -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
};
}

View File

@ -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 |

View File

@ -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
View File

@ -10,6 +10,7 @@ export type NotifyOptions = {
className?: any;
background?: string;
onClose?: (() => void) | null;
onOpened?: (() => void) | null;
onClick?: ((event: Event) => void) | null;
}