npm i --save nativescript-loading-indicator-ssi
- 版本: 2.5.2
- GitHub: https://github.com/simplec-dev/nativescript-loading-indicator
- NPM: https://npmjs.net.cn/package/nativescript-loading-indicator-ssi
- 下载量
- 昨日: 0
- 上周: 0
- 上个月: 0
nativescript-loading-indicator
nativescript-loading-indicator 是一个 NativeScript 插件,可以在当前页面上覆盖显示加载指示器。可用于,例如,在从 API 获取数据时防止与 UI 进行交互,同时告知用户有操作正在进行。
- iOS: MBProgressHUD
- Android: ProgressDialog
安装
tns plugin add nativescript-loading-indicator
示例
var LoadingIndicator = require("nativescript-loading-indicator").LoadingIndicator;
// or with TypeScript:
// import {LoadingIndicator} from "nativescript-loading-indicator";
var loader = new LoadingIndicator();
// optional options
// android and ios have some platform specific options
var options = {
message: 'Loading...',
progress: 0.65,
android: {
indeterminate: true,
cancelable: false,
max: 100,
progressNumberFormat: "%1d/%2d",
progressPercentFormat: 0.53,
progressStyle: 1,
secondaryProgress: 1
},
ios: {
details: "Additional detail note!",
margin: 10,
dimBackground: true,
color: "#4B9ED6", // color of indicator and labels
// background box around indicator
// hideBezel will override this if true
backgroundColor: "yellow",
hideBezel: true, // default false, can hide the surrounding bezel
view: UIView, // Target view to show on top of (Defaults to entire window)
mode: // see iOS specific options below
}
};
loader.show(options); // options is optional
// Do whatever it is you want to do while the loader is showing, then
loader.hide();
选项
- message:
string
您的消息! - progress:
number
设置进度显示
Android 特定
- 参考: https://android-docs.cn/intl/zh-tw/reference/android/app/ProgressDialog.html
iOS 特定
- 参考: https://github.com/jdg/MBProgressHUD/blob/master/Demo/Classes/MBHudDemoViewController.m
快速 模式
参考
MBProgressHUDModeDeterminate
MBProgressHUDModeAnnularDeterminate
MBProgressHUDModeDeterminateHorizontalBar
MBProgressHUDModeText
MBProgressHUDModeCustomView
- 使用
customView: string
- 本地图片文件路径
- 使用