fix(Dialog): missing emits config

This commit is contained in:
chenjiahan 2020-07-26 16:54:15 +08:00
parent 040418dcd9
commit 49206598fc
2 changed files with 10 additions and 6 deletions

View File

@ -47,6 +47,8 @@ export default createComponent({
},
},
emits: ['opened', 'closed', 'confirm', 'cancel', 'update:show'],
data() {
return {
loading: {

View File

@ -17,9 +17,12 @@ function initInstance() {
};
},
methods: {
onToggle(show) {
toggle(show) {
this.dialogProps.show = show;
},
setProps(props) {
this.dialogProps = props;
},
},
render() {
return (
@ -27,7 +30,7 @@ function initInstance() {
lazyRender={false}
{...{
...this.dialogProps,
'onUpdate:show': this.onToggle,
'onUpdate:show': this.toggle,
}}
/>
);
@ -46,22 +49,21 @@ function Dialog(options) {
initInstance();
}
instance.dialogProps = {
instance.setProps({
...Dialog.currentOptions,
...options,
callback: (action) => {
(action === 'confirm' ? resolve : reject)(action);
},
};
});
nextTick(() => {
instance.dialogProps.show = true;
instance.toggle(true);
});
});
}
Dialog.defaultOptions = {
show: false,
title: '',
width: '',
message: '',