nativescript-loading-screen
为 Android 和 iOS 应用提供加载屏幕的插件。
npm i --save nativescript-loading-screen

Nativescript Loading Screen apple android

这是我第一个插件,请多多包涵 :) :P

此插件为 iOS 和 Android 应用添加加载屏幕。

安装

tns plugin add nativescript-loading-screen

使用

import { Observable } from 'tns-core-modules/data/observable';
import { LoadingScreen } from 'nativescript-loading-screen';

export class HelloWorldModel extends Observable {
private loadingScreen: LoadingScreen;

constructor() {
super();
}

public showLoading() {
this.loadingScreen = new LoadingScreen();

this.loadingScreen.show({
title: "test",
message: "loading..."
});

setTimeout(() => {
this.loadingScreen.updateMessage("Loading Change");
}, 5000);

setTimeout(() => {
this.loadingScreen.close();
const topmost = frameModule.topmost();
topmost.navigate("details-page");
}, 10000);

}
}

如果您计划在关闭加载屏幕后进行 nativate,您必须在 iOS 上的已解析的 promise 中这样做。下面是示例

  this.loadingScreen.close().then((result) => {
console.log(`Result => ${result}`);

});

API

方法 返回值 描述
show(options?: Options) Promise<bool> 显示加载屏幕
update(options?: Options) Promise<bool> 更新消息和标题
updateMessage(message: string) Promise<bool> 更新消息
updateTitle(title: string) Promise<bool> 更新标题
close() Promise<bool> 关闭加载屏幕

选项

属性 类型 默认值 描述
title string [blank] 用于加载屏幕的标题
message string loading... 用于加载屏幕的消息

许可证

Apache 许可证版本 2.0,2004 年 1 月

致谢

我从 Vladimir Enchev @enchev 编写的 nativescript-dialog 获得了制作此插件的灵感