gpt4 book ai didi

javascript - 尝试在 create-react-native-app 项目中使用 react-native-fs (expo)

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:29:40 27 4
gpt4 key购买 nike

我正在尝试在我的应用程序中使用 react-native-fs 来上传文件等。我按照文档进行了安装,进行了导入,然后我将这段代码用于测试:

componentDidMount(){
const path = RNFS.DocumentDirectoryPath + '/test.txt';
console.log(path);
// write the file
RNFS.writeFile(path, 'Lorem ipsum dolor sit amet', 'utf8')
.then((success) => {
console.log('FILE WRITTEN!');
})
.catch((err) => {
console.log(err.message);
});
}

它直接给我这个错误:

enter image description hereps: 我通过 create-react-native-app 创建了我的项目

有什么想法吗?

最佳答案

您的项目中需要链接 react-native fs。在终端 react-native link react-native-fs 中运行它

关于javascript - 尝试在 create-react-native-app 项目中使用 react-native-fs (expo),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47923076/

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