diff --git a/examples/docs/en-US/message-box.md b/examples/docs/en-US/message-box.md index 9f15b836c..a79aea98b 100644 --- a/examples/docs/en-US/message-box.md +++ b/examples/docs/en-US/message-box.md @@ -100,6 +100,28 @@ }, open6() { + this.$confirm('You have unsaved changes, save and proceed?', 'Confirm', { + distinguishCancelAndClose: true, + confirmButtonText: 'Save', + cancelButtonText: 'Discard Changes' + }) + .then(() => { + this.$message({ + type: 'info', + message: 'Changes saved. Proceeding to a new route.' + }); + }) + .catch(action => { + this.$message({ + type: 'info', + message: action === 'cancel' + ? 'Changes discarded. Proceeding to a new route.' + : 'Stay in the current route' + }) + }); + }, + + open7() { this.$confirm('This will permanently delete the file. Continue?', 'Warning', { confirmButtonText: 'OK', cancelButtonText: 'Cancel', @@ -292,6 +314,7 @@ The content of MessageBox can be `VNode`, allowing us to pass custom components. ::: ### Use HTML String + `message` supports HTML string. :::demo Set `dangerouslyUseHTMLString` to true and `message` will be treated as an HTML string. @@ -319,10 +342,11 @@ The content of MessageBox can be `VNode`, allowing us to pass custom components. Although `message` property supports HTML strings, dynamically rendering arbitrary HTML on your website can be very dangerous because it can easily lead to [XSS attacks](https://en.wikipedia.org/wiki/Cross-site_scripting). So when `dangerouslyUseHTMLString` is on, please make sure the content of `message` is trusted, and **never** assign `message` to user-provided content. ::: -### Centered content -Content of MessageBox can be centered. +### Distinguishing cancel and close -:::demo Setting `center` to `true` will center the content +In some cases, clicking the cancel button and close button may have different meanings. + +:::demo By default, the parameters of Promise's reject callback and `callback` are 'cancel' when the user cancels (clicking the cancel button) and closes (clicking the close button or mask layer, pressing the ESC key) the MessageBox. If `distinguishCancelAndClose` is set to true, the parameters of the above two operations are 'cancel' and 'close' respectively. ```html