diff --git a/examples/docs/en-US/message-box.md b/examples/docs/en-US/message-box.md index 8f5f434aa..25698c7bf 100644 --- a/examples/docs/en-US/message-box.md +++ b/examples/docs/en-US/message-box.md @@ -64,7 +64,21 @@ message: 'This is a message', showCancelButton: true, confirmButtonText: 'OK', - cancelButtonText: 'Cancel' + cancelButtonText: 'Cancel', + beforeClose: (action, instance) => { + if (action === 'confirm') { + instance.confirmButtonLoading = true; + instance.confirmButtonText = 'Loading...'; + setTimeout(() => { + instance.close(); + setTimeout(() => { + instance.confirmButtonLoading = false; + }, 300); + }, 3000); + } else { + instance.close(); + } + } }).then(action => { setTimeout(() => { this.$message({ @@ -194,7 +208,7 @@ Prompt is used when user input is required. Can be customized to show various content. -:::demo The three methods mentioned above are repackagings of the `$msgbox` method. This example calls `$msgbox` method directly using the `showCancelButton` attribute, which is used to indicate if a cancel button is displayed. Besides we can use `cancelButtonClass` to add a custom style and `cancelButtonText` to customize the button text. The confirm button also has these fields. A complete list of fields can be found at the end of this documentation. +:::demo The three methods mentioned above are repackagings of the `$msgbox` method. This example calls `$msgbox` method directly using the `showCancelButton` attribute, which is used to indicate if a cancel button is displayed. Besides we can use `cancelButtonClass` to add a custom style and `cancelButtonText` to customize the button text (the confirm button also has these fields, and a complete list of fields can be found at the end of this documentation). This example also uses the `beforeClose` attribute. It is a method and will be triggered when the MessageBox instance will be closed, and its execution will stop the instance from closing. It has two parameters: `action` and `instance`. Using it enables you to manipulate the instance before it closes, e.g. activating `loading` for confirm button; you can invoke the `close` method registered on the instance to close the MessageBox instance. ```html