diff --git a/src/dialog/Dialog.js b/src/dialog/Dialog.js index 85e84a27a..c1ade262a 100644 --- a/src/dialog/Dialog.js +++ b/src/dialog/Dialog.js @@ -47,6 +47,8 @@ export default createComponent({ }, }, + emits: ['opened', 'closed', 'confirm', 'cancel', 'update:show'], + data() { return { loading: { diff --git a/src/dialog/index.js b/src/dialog/index.js index 0166c394b..0a10a875d 100644 --- a/src/dialog/index.js +++ b/src/dialog/index.js @@ -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: '',