Storage

Storage

new Storage()

Storage 类

存储专用雷,处理 localStorage,调用如下:

// 非法调用
const storage = new Storage();

// 合法调用
import Ux from 'ux';
const value = Ux.Storage.get("testKey");

Methods

(static) clear()

清除 localStorage 中的所有数据。

(static) get(key) → {any}

Parameters:
Name Type Description
key String

将要读取 storage 中的键值。

Returns:

返回读取的数据

Type
any

(static) getDirect(key) → {any}

内部调用代码例子

const appKey = Ut.Storage.getDirect(Cv.X_APP_KEY);
if (appKey) headers.append(Cv.X_HEADER.X_APP_KEY, appKey);

const appId = Ut.Storage.getDirect(Cv.X_APP_ID);
if (appId) headers.append(Cv.X_HEADER.X_APP_ID, appId);

const sigma = Ut.Storage.getDirect(Cv.X_SIGMA);
if (sigma) headers.append(Cv.X_HEADER.X_SIGMA, sigma);
Parameters:
Name Type Description
key String

将要读取 storage 中的键值。

Returns:

返回的直接数据

Type
any

(static) put(key, value)

Parameters:
Name Type Description
key String

将要写入 storage 的键。

value any

将要写入 storage 中的键对应的值。

(static) putDirect(key, value)

Parameters:
Name Type Description
key
value

(static) remove(key)

Parameters:
Name Type Description
key String

将要移除的 storage 中键值。