1.0.8 • Published 2 years ago
@uni/confirm v1.0.8
confirm
Displays the modal dialog box.
Supported
Install
$ npm install @uni/confirm --save
or
$ npm install @uni/apis --save
Usage
import confirm from '@uni/confirm';
confirm({
title: '提示',
content: '这是一个模态弹窗',
success (res) {
if (res.confirm) {
console.log('用户点击确定')
} else if (res.cancel) {
console.log('用户点击取消')
}
}
});
// promise
confirm({
title: '提示',
content: '这是一个模态弹窗'
}).then(res => {
if (res.confirm) {
console.log('用户点击确定')
} else if (res.cancel) {
console.log('用户点击取消')
}
});
You can also import from the big package:
import { confirm } from '@uni/apis';
Methods
confirm(options)
Arguments
Property | Type | Description | required | Default |
---|---|---|---|---|
options | object | ✔️ | - | |
options.title | string | Prompt title | ✘ | - |
options.content | string | Prompt content | ✘ | - |
options.confirmText | string | The text of the "OK "button, not more than 4 characters | ✘ | "OK" |
options.cancelText | string | The text of the "Cancel" button, not more than 4 characters | ✘ | "Cancel" |
options.success | Function | The callback function for a successful API call | ✘ | - |
options.fail | Function | The callback function for a failed API call | ✘ | - |
options.complete | Function | The callback function used when the API call completed (always executed whether the call succeeds or fails) | ✘ | - |
Special Arguments
Property | Type | Description | required | Default | Supported |
---|---|---|---|---|---|
options.showCancel | boolean | Indicates whether to display the "Cancel" button | ✘ | true | |
options.cancelColor | string | The text color of the "Cancel" button, which must be a color string in hexadecimal format | ✘ | #000000 | |
options.confirmColor | string | The text color of the "OK" button, which must be a color string in hexadecimal format | ✘ | #576B95 |
Return
Property | Type | Description | Support |
---|---|---|---|
confirm | boolean | When the value is "true", it indicates that the user tapped the "OK" button. | |
cancel | boolean | When the value is "true", it indicates that the user tapped the "Cancel" button. (this is used for Android system to distinguish whether "Mask" or "Cancel" is tapped) |
1.0.8
2 years ago
1.0.8-alpha.0
2 years ago
1.0.7
4 years ago
1.0.6
4 years ago
1.0.5
4 years ago
1.0.4
4 years ago
1.0.4-beta
4 years ago
1.0.3
4 years ago
1.0.2
4 years ago
1.0.1
4 years ago
1.0.0
4 years ago
1.0.0-beta1
4 years ago
1.0.0-beta
4 years ago