2.0.0-beta • Published 3 years ago
universal-show-modal v2.0.0-beta
showModal
Displays the modal dialog box.
Supported
Install
$ npm install universal-showModal --save
or
$ npm install universal-api --save
Usage
import showModal from 'universal-showModal';
showModal({
title: '提示',
content: '这是一个模态弹窗',
success (res) {
if (res.confirm) {
console.log('用户点击确定')
} else if (res.cancel) {
console.log('用户点击取消')
}
}
});
// promise
showModal({
title: '提示',
content: '这是一个模态弹窗'
}).then(res => {
if (res.confirm) {
console.log('用户点击确定')
} else if (res.cancel) {
console.log('用户点击取消')
}
});
You can also import from the big package:
import { showModal } from 'universal-api';
Methods
showModal(options)
Arguments
Property | Type | Description | required | Default |
---|---|---|---|---|
options | object | ✔️ | - | |
options.title | string | Prompt title | ✘ | - |
options.content | string | Prompt content | ✘ | - |
options.showCancel | boolean | Indicates whether to display the "Cancel" button | ✘ | true |
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) | ✘ | - |
Return
Property | Type | Description |
---|---|---|
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) |
/**
* iframe: true
*/
import React from 'react';
export default () => (
<iframe style={{
boxShadow: '0 2px 15px rgba(0,0,0,0.1)',
width: '375px',
height: '700px'
}} src='https://herbox.online/p/109000004/app_1aKtEd7SK?previewZoom=100&view=preview&defaultPage=pages/universal-show-modal/index&topSlider=false'></iframe>
);
2.0.0-beta
3 years ago