npm i --save nativescript-sweet-alert
- 版本:1.0.4
- GitHub: https://github.com/NazimMertBilgi/nativescript-sweet-alert
- NPM: https://npmjs.net.cn/package/nativescript-sweet-alert
- 下载量
- 昨日:1
- 上周:2
- 上月:11
SweetAlert 库用于 NativeScript Android。
基于
- Android F0RIS/sweet-alert-dialog
安装
NativeScript 6x
tns plugin add nativescript-sweet-alert

Android 规格
使用示例
注意:“options”可能根据每个方法而有所不同。
import { SweetAlert } from 'nativescript-sweet-alert';
import { ShowSuccess , ShowError } from 'nativescript-sweet-alert/classes';
// showSuccess
const options: ShowSuccess = {
text: "Hello",
contentText: "Alert Content Text",
confirmButtonText: "Ok",
cancelButtonText: "Close"
}
SweetAlert.showSuccess(options).then(value => {
// result: true, false, CLOSED
});
// showError
const options: ShowError = {
text: "Hello",
contentText: "Alert Content Text",
confirmButtonText: "Ok",
cancelButtonText: "Close"
}
SweetAlert.showError(options).then(value => {
// result: true, false, CLOSED
});
NativeScript SweetAlert - 方法
showNormal(options: ShowNormal): Promise<any>
showError(options: ShowError): Promise<any>
showSuccess(options: ShowSuccess): Promise<any>
showWarning(options: ShowWarning): Promise<any>
showCustomImage(options: ShowCustomImage): Promise<any>
showText(options: ShowText): Promise<any>
showCheckbox(options: ShowCheckbox): Promise<any>
如何更改颜色?
在 App_Resources/Android/src/main/res/values/colors.xml 中添加到 颜色属性
为什么使用 TNS 前缀的名称?
TNS
代表 Telerik NativeScript
iOS 使用以 NS
为前缀的类(源自于古老的 NeXTSTEP 时代):https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/
为了避免与 iOS 本地类混淆,使用 TNS
而不是 NS
。
演示
需要额外帮助以将这些 SweetAlert 应用到您的应用程序中?请查看这些使用该插件的教程
SweetAlert 在 NativeScript Core 演示
SweetAlert 在 NativeScript Angular 演示
许可
MIT