React Native官网对AsyncStorage的API:
http://reactnative.cn/docs/0.47/asyncstorage.html
核心代码:
AsyncStorage.getItem(key).then(
(value) => {
// 逻辑判断
AsyncStorage.setItem(key, value);
}
)
注意:这里的value值必须是string类型的,否则会报错。
因为AsyncStorage.setItem expects a non-null key and value. 所以如果你要用AsyncStorage.setItem置空来清除缓存是不行的,请使用removeItem或者clear方法即可。
本文介绍了React Native中AsyncStorage的基本用法及注意事项,包括如何获取、设置缓存项,并强调了值必须为字符串类型的要求,同时指出置空缓存应使用removeItem或clear方法。
6323

被折叠的 条评论
为什么被折叠?



