我在使用 rn-fetch-blob 访问 React Native 中的本地资源时遇到问题,这是我的目录结构:
我想从 App.js 访问文件 Female.png,这是我的脚本:
RNFetchBlob.fs.readFile('./female.png', 'base64')
.then((data) => {
console.log(data);
})
Run Code Online (Sandbox Code Playgroud)
我总是收到这个错误:
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
Run Code Online (Sandbox Code Playgroud)
请任何人帮助我使用 rn-fetch-blob 访问本地资产。
谢谢。
| 归档时间: |
|
| 查看次数: |
846 次 |
| 最近记录: |