diff --git a/demo/documentation/components/confirm/enUS/async.md b/demo/documentation/components/confirm/enUS/async.md index 0135138c6..a4d2e8bf8 100644 --- a/demo/documentation/components/confirm/enUS/async.md +++ b/demo/documentation/components/confirm/enUS/async.md @@ -1,28 +1,32 @@ # Async + ```html Success ``` + ```css .n-button { margin: 0 12px 8px 0; } ``` + ```js export default { methods: { - handleClick (e) { + handleClick(e) { const confirmInstance = this.$NModal.success({ title: "Success", content: "Premium designed icons for use in web, iOS, Android, and desktop apps. Support for SVG and web font. Completely open source, MIT licensed and built by the Ionic Framework team.", - onPositiveClick: (hide) => { + onPositiveClick: hide => { + confirmInstance.loading = true; this.$NMessage.success("count down 1 second"); - window.setTimeout(hide, 1000) + window.setTimeout(hide, 1000); } }); } } }; -``` \ No newline at end of file +``` diff --git a/packages/common/Confirm/src/confirm.vue b/packages/common/Confirm/src/confirm.vue index 77f6711fb..5c4ff3f4e 100644 --- a/packages/common/Confirm/src/confirm.vue +++ b/packages/common/Confirm/src/confirm.vue @@ -47,12 +47,13 @@ :theme="theme" round :disabled="loading === true" + :loading="loading" size="small" type="primary" auto-text-color @click="handlePositiveClick" > - {{ loading === true ? "Loading" : positiveText }} + {{positiveText}} diff --git a/packages/common/Confirm/src/index.js b/packages/common/Confirm/src/index.js index 18d7098ac..cc5ef14f0 100644 --- a/packages/common/Confirm/src/index.js +++ b/packages/common/Confirm/src/index.js @@ -1,4 +1,3 @@ - import Confirm from './confirm.vue' const instances = new Set() @@ -23,30 +22,42 @@ export default { }, confirm (options) { const instance = this.createInstance() - setDataOnConfirmInstance({ - type: 'confirm', - active: true, - theme: this.theme, - ...options - }, instance) + setDataOnConfirmInstance( + { + type: 'confirm', + active: true, + theme: this.theme, + ...options + }, + instance + ) + return instance }, error (options) { const instance = this.createInstance() - setDataOnConfirmInstance({ - type: 'error', - active: true, - theme: this.theme, - ...options - }, instance) + setDataOnConfirmInstance( + { + type: 'error', + active: true, + theme: this.theme, + ...options + }, + instance + ) + return instance }, success (options) { const instance = this.createInstance() - setDataOnConfirmInstance({ - type: 'success', - active: true, - theme: this.theme, - ...options - }, instance) + setDataOnConfirmInstance( + { + type: 'success', + active: true, + theme: this.theme, + ...options + }, + instance + ) + return instance }, destroyAll () { instances.forEach(instance => {