gpt4 book ai didi

react-native - 为什么我在使用 AsyncStorage 时会收到 "_reactNative.AsyncStorage.setItem is not a function"错误?

转载 作者:行者123 更新时间:2023-12-02 04:35:22 28 4
gpt4 key购买 nike

我正在使用 AsyncStorage在 React Native 中,但我的问题总是出错

_reactNative.AsyncStorage.setItem is not a function



当我使用 AsyncStorage.setItem ?

这是一些代码

enter image description here

并出现错误:(
enter image description here

更新:问题解决了。
您不应该使用 react-native 的任何组件的相同名称来命名您的项目

最佳答案

如果要存储对象,则应在构造函数中绑定(bind)函数并使用 JSON.stringify

关于react-native - 为什么我在使用 AsyncStorage 时会收到 "_reactNative.AsyncStorage.setItem is not a function"错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43866049/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com