2.0.0-beta • Published 3 years ago

universal-show-modal v2.0.0-beta

Weekly downloads
2
License
BSD-3-Clause
Repository
-
Last release
3 years ago

showModal

npm npm

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

PropertyTypeDescriptionrequiredDefault
optionsobject ✔️-
options.titlestring Prompt title-
options.contentstring Prompt content-
options.showCancelboolean Indicates whether to display the "Cancel" buttontrue
options.confirmTextstring The text of the "OK "button, not more than 4 characters"OK"
options.cancelTextstring The text of the "Cancel" button, not more than 4 characters"Cancel"
options.successFunction The callback function for a successful API call-
options.failFunction The callback function for a failed API call-
options.completeFunction The callback function used when the API call completed (always executed whether the call succeeds or fails)-

Return

PropertyTypeDescription
confirmboolean When the value is "true", it indicates that the user tapped the "OK" button.
cancelboolean 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>
);