Starting from version 1078, the API prefix has been changed from hbs to qg. The original prefix hbs is still supported.
API | Description |
|---|---|
Displays a toast. | |
Displays a modal. | |
Displays a loading pop-up. | |
Displays the operation menu. | |
Hides a toast. | |
Hides a loading pop-up. |
Parameter | Type | Default Value | Mandatory | Description |
|---|---|---|---|---|
title | string | - | No | Toast title. Either title or message must be set. If this parameter is not passed, the value of message will be displayed. |
icon | string | 'success' | No | Icon to be displayed. The options are as follows:
|
image | string | - | No | Custom icon path. The priority of image is higher than that of icon. |
message(1078+) | string | - | No | Toast content. Either title or message must be set, and the value of title is displayed preferentially. |
duration | number | 0 or 1500 | No | Duration for displaying the toast.
|
mask | boolean | - | No | Indicates whether to display the clear mask.
|
success | function | - | No | Callback function triggered upon a successful API call. |
fail | function | - | No | Callback function triggered upon a failed API call. |
complete | function | - | No | If a function is passed, it will be called regardless of whether the API call succeeds or fails. |
qg.showToast({
title: 'Success',
icon: 'success',
duration: 2000
}) Parameter | Type | Default Value | Mandatory | Description |
|---|---|---|---|---|
title | string | - | No | Modal title. |
content | string | - | No | Modal content. |
showCancel | boolean | true | No | Indicates whether to display a cancel button. |
cancelText | string | Cancel | No | Text on the cancel button. The value contains up to four characters. |
cancelColor | string | #576B95 | No | Color of the text on the cancel button. The value must be a hexadecimal character string that specifies a color. |
confirmText | string | OK | No | Text on the confirm button. The value contains up to four characters. |
confirmColor | string | #576B95 | No | Color of the text on the confirm button. The value must be a hexadecimal character string that specifies a color. |
success | function | - | No | Callback function triggered upon a successful API call. For details, please refer to Parameters in the success callback function. |
fail | function | - | No | Callback function triggered upon a failed API call. |
complete | function | - | No | If a function is passed, it will be called regardless of whether the API call succeeds or fails. |
qg.showModal({
title: 'Tips',
content: 'This is a modal.',
success (res) {
if (res.confirm) {
console.log('The user taps OK.')
} else if (res.cancel) {
console.log('The user taps Cancel.')
}
}
}) Displays a loading pop-up. The pop-up can be closed only after qg.hideLoading is called.
Parameter | Type | Default Value | Mandatory | Description |
|---|---|---|---|---|
title | string | - | Yes | Pop-up content. |
mask | boolean | false | No | Indicates whether to display the clear mask. Set this parameter to true to block touch events. |
success | function | - | No | Callback function triggered upon a successful API call. For details, please refer to Parameters in the success callback function. |
fail | function | - | No | Callback function triggered upon a failed API call. |
complete | function | - | No | If a function is passed, it will be called regardless of whether the API call succeeds or fails. |
qg.showLoading({
title: 'Loading',
})
setTimeout(function () {
qg.hideLoading()
}, 2000) Parameter | Type | Default Value | Mandatory | Description |
|---|---|---|---|---|
itemList | array string | - | Yes | Array of button text labels, with a maximum length of six items. |
itemColor | string | #000000 | No | Button color. |
success | function | - | No | Callback function triggered upon a successful API call. For details, please refer to Parameters in the success callback function. |
fail | function | - | No | Callback function triggered upon a failed API call. |
complete | function | - | No | If a function is passed, it will be called regardless of whether the API call succeeds or fails. |
qg.showActionSheet({
itemList: ['A', 'B', 'C'],
success (res) {
console.log(res)
},
fail (res) {
console.log(res.errMsg)
}
}) Parameter | Type | Default Value | Mandatory | Description |
|---|---|---|---|---|
success | function | - | No | Callback function triggered upon a successful API call. |
fail | function | - | No | Callback function triggered upon a failed API call. |
complete | function | - | No | If a function is passed, it will be called regardless of whether the API call succeeds or fails. |
qg.hideToast ({
success (res) {
console.log('success')
},
fail (res) {
console.log('fail')
}
}) Parameter | Type | Default Value | Mandatory | Description |
|---|---|---|---|---|
success | function | - | No | Callback function triggered upon a successful API call. |
fail | function | - | No | Callback function triggered upon a failed API call. |
complete | function | - | No | If a function is passed, it will be called regardless of whether the API call succeeds or fails. |
qg.hideLoading ({
success (res) {
console.log('success')
},
fail (res) {
console.log('fail')
}
})