是否有用于数据缓存的主动维护的nativescript插件?
与nativescript-cache
类似,但遗憾的是这个插件现在处于非活动状态。
答案 0 :(得分:0)
您可以使用nativescript核心模块application-settings
。它与nativescript-cache
插件完全相同。
import {
getBoolean,
setBoolean,
getNumber,
setNumber,
getString,
setString,
hasKey,
remove,
clear
} from "application-settings";
Set and get boolean value and provide default value in case it is not set
setBoolean("isTurnedOn", true);
this.isTurnedOn = getBoolean("isTurnedOn", true);
Set and get string value
setString("username", "Wolfgang");
this.username = getString("username");
Set and get numeric value.
setNumber("locationX", 54.321);
this.locationX = parseFloat(getNumber("locationX").toFixed(3));
Reading values that are not set before while providing default value
// will return "No string value" if there is no value for "noSuchKey"
this.someKey = getString("noSuchKey", "No string value");
有关详细信息,请参阅nativescript文档:https://docs.nativescript.org/angular/code-samples/application-settings