React native之全局变量存储AsyncStorage
AsyncStorage是React native中对变量,对象进行全局存储,读取的异步使用对象。以key值进行存储。但是只能存储字符串数据,想存储对象,可把对象JSON进行序列化存储,读取的时候再转成JSON对象。
AsyncStorage.getItem()---读取变量
AsyncStorage.setItem()---存储变量
AsyncStorage.removeItem()---移除key值的存储
因为是异步的,调用时:
const A = await AsyncStorage.getItem(
key
);
原文地址:https://blog.csdn.net/wanghonghongkx/article/details/142878672
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!