react-native - 如何使用 rn-fetch-blob 在 React Native 中访问本地资产?
问题描述
我在使用 rn-fetch-blob 访问 React Native 中的本地资产时遇到问题,这是我的目录结构:
我想从 App.js 访问文件 female.png,这是我的脚本:
RNFetchBlob.fs.readFile('./female.png', 'base64')
.then((data) => {
console.log(data);
})
我总是得到这个错误:
Possible Unhandled Promise Rejection (id: 14):
Error: No such file './female.png'; ./female.png (No such file or directory)
Error: No such file './female.png'; ./female.png (No such file or directory)
at createErrorFromErrorData (blob:http://localhost:8081/61bf342c-3b22-4e66-9eea-bf93a115f88e:16416:17)
at blob:http://localhost:8081/61bf342c-3b22-4e66-9eea-bf93a115f88e:16368:27
at MessageQueue.__invokeCallback (blob:http://localhost:8081/61bf342c-3b22-4e66-9eea-bf93a115f88e:17245:18)
at blob:http://localhost:8081/61bf342c-3b22-4e66-9eea-bf93a115f88e:16976:18
at MessageQueue.__guard (blob:http://localhost:8081/61bf342c-3b22-4e66-9eea-bf93a115f88e:17149:13)
at MessageQueue.invokeCallbackAndReturnFlushedQueue (blob:http://localhost:8081/61bf342c-3b22-4e66-9eea-bf93a115f88e:16975:14)
at http://localhost:8081/debugger-ui/debuggerWorker.js:80:58
请任何人帮助我使用 rn-fetch-blob 访问本地资产。
谢谢。
解决方案
推荐阅读
- mongodb - 将monogdb集合中的数据导出到grafana
- android - Android Studio:“AVD Pixel_2_API_30 的模拟器进程已终止。” 在 MacBook Pro M1(Apple Silicon)上
- firebase - A/B 测试:事件计数指标,而不是转化指标
- solr - solr 在带有冒号的 id 上流式传输最短路径错误
- php - 如何在不同的引导选项卡上调用 ajax?
- javascript - 如何使用 docxtemplater 在 word 文件中构建列表?
- vba - Word表格单元格上的条件格式,在每个单元格值更改后自动运行
- sql - 如何显示客户之前的 2 个订单?
- javascript - 通过 Livewire 插入 AlpineJS 会导致未处理的 Promise Rejection: ReferenceError: Can't find variable
- marklogic - 当我在 MarkLogic 的 content.xqy 中使用左外连接时,协调速度变慢