1

是否有用于数据缓存的积极维护的 nativescript 插件?

喜欢nativescript-cache但遗憾的是这个插件现在不活动了。

4

1 回答 1

0

您可以使用 nativescript 核心模块application-settingsnativescript-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

于 2018-05-24T09:33:11.623 回答