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() { data() {
return { return {
loading: { loading: {

View File

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