![](/img/trans.png)
[英]How to access file system (like react-native-fs module) with create-react-app project?
[英]Try to use react-native-fs in create-react-native-app project (expo)
我正在尝试在我的应用程序中使用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);
});
}
它直接给我这个错误:
ps:我通过create-react-native-app创建了我的项目
有任何想法吗?
您需要在项目中链接react-native fs。 在终端react-native链路react-native-fs中运行它
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.