[improvement] Notify: improve event binding (#3640)

This commit is contained in:
neverland 2019-06-26 14:26:03 +08:00 committed by GitHub
parent c6f8fca41f
commit 344b105e0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 15 deletions

View File

@ -1,6 +1,6 @@
import { use } from '../utils'; import { use } from '../utils';
import { RED, WHITE } from '../utils/color'; import { RED, WHITE } from '../utils/color';
import { emit, inherit } from '../utils/functional'; import { inherit } from '../utils/functional';
import { PopupMixin } from '../mixins/popup'; import { PopupMixin } from '../mixins/popup';
import Popup from '../popup'; import Popup from '../popup';
@ -38,16 +38,7 @@ function Notify(
overlay={false} overlay={false}
lockScroll={false} lockScroll={false}
class={[bem(), props.className]} class={[bem(), props.className]}
onInput={(value: boolean) => { {...inherit(ctx, true)}
emit(ctx, 'input', value);
}}
onClick={(event: Event) => {
emit(ctx, 'click', event);
}}
onOpened={() => {
emit(ctx, 'opened');
}}
{...inherit(ctx)}
> >
{props.message} {props.message}
</Popup> </Popup>

View File

@ -26,6 +26,11 @@ function Notify(options: NotifyOptions) {
instance.onClick(event); instance.onClick(event);
} }
}, },
close() {
if (instance.onClose) {
instance.onClose();
}
},
opened() { opened() {
if (instance.onOpened) { if (instance.onOpened) {
instance.onOpened(); instance.onOpened();
@ -67,10 +72,6 @@ function defaultOptions(): NotifyOptions {
Notify.clear = () => { Notify.clear = () => {
if (instance) { if (instance) {
instance.value = false; instance.value = false;
if (instance.onClose) {
instance.onClose();
}
} }
}; };