1.0.8 • Published 2 years ago

@uni/confirm v1.0.8

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

confirm

npm

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

PropertyTypeDescriptionrequiredDefault
optionsobject ✔️-
options.titlestring Prompt title-
options.contentstring Prompt content-
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)-

Special Arguments

PropertyTypeDescriptionrequiredDefaultSupported
options.showCancelbooleanIndicates whether to display the "Cancel" buttontrue
options.cancelColorstringThe text color of the "Cancel" button, which must be a color string in hexadecimal format#000000
options.confirmColorstringThe text color of the "OK" button, which must be a color string in hexadecimal format#576B95

Return

PropertyTypeDescriptionSupport
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)
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