![](/img/trans.png)
[英]How to push multiple items into an array and load into async storage in react native?
[英]How to set array of object inside async storage in react native
我正在嘗試在異步存儲中設置 object 數組,但我沒有設置它。 有人可以幫助我如何實現這一目標。 謝謝
代碼
let joined = this.state.product.concat(product);
this.props.setNotification(joined);
AsyncStorage.setItem("count", joined);
最簡單的方法是將數組字符串化並存儲
AsyncStorage.setItem('count', JSON.stringify(joined));
檢索字符串時必須對其進行解析
const storedArray = await AsyncStorage.getItem('count');
const array = JSON.parse(storedArray)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.