Skip to content

本地存储模块 ​

集成和使用ESLocalStorage模块。

"@extscreen/es-core": "2.3.8"及以上版本支持

本地存储模块支持一下类型的数据:

  • Boolean
  • Int
  • Long
  • String

集成 ​

package.json引入库

点击查看源码
js
"@extscreen/es-core": "2.3.8"

使用默认存储名称API ​

getLocalBoolean(key, defValue)
putLocalBoolean(key, value)
getLocalInt(key, defValue)
putLocalInt(key, value)
getLocalLong(key, defValue)
putLocalLong(key, value)
getLocalString(key, defValue)
putLocalString(key, value)

使用自定义存储名称API ​

getBoolean(storageName, key, defValue)
putBoolean(storageName, key, value)
getInt(storageName, key, defValue)
putInt(storageName, key, value)
getLong(storageName, key, defValue)
putLong(storageName, key, value)
getString(storageName, key, defValue)
putString(storageName, key, value)

存储默认存储名称数据 ​

示例代码

点击查看源码
js
//存储key为boolean_key的数据,值为true
ESLocalStorage.putLocalBoolean('boolean_key', true).then(
    (result) => {
    },
    error => {
    }
)

获取默认存储名称数据 ​

示例代码

点击查看源码
js
//获取存储key为boolean_key的数据,默认值值为true
ESLocalStorage.getLocalBoolean('boolean_key', true).then(
    (result) => {
    },
    error => {
    }
)

存储自定义存储名称数据 ​

示例代码

点击查看源码
js
//存储key为boolean_key的数据,值为true
ESLocalStorage.putBoolean('自定义存储名称', 'boolean_key', true).then(
    (result) => {
    },
    error => {
    }
)

获取自定义存储名称数据 ​

示例代码

点击查看源码
js
//获取存储key为boolean_key的数据,默认值值为true
ESLocalStorage.getBoolean('自定义存储名称', 'boolean_key', true).then(
    (result) => {
    },
    error => {
    }
)