问题描述
我已经查看了 wiki 的故障排除页面,但我仍然无法解决我遇到的问题.
I have looked at the trouble shooting page of the wiki, however I still cannot fix the problem I am having.
react-native-cli: 2.0.1
react-native: 0.43.4
我的代码:
从react-native-file-uploader"导入 FileUploader
和
<Button
onPress={() => RNFetchBlob.fetch('POST', 'http://localhost:8000/upload', {
'Content-Type' : 'application/octet-stream'
}, RNFetchBlob.wrap('./tempImageStore/image.jpg'))
}
title={'Upload File'}
/>
我得到的错误:
1) npm install --save github:wkh237/react-native-fetch-blob-package#master
2) react-native 链接
- 我尝试使用
import RNFetchBlob from 'react-native-fetch-blob'
和var RNFetchBlob = require('react-native-fetch-blob').default 来导入它
- 我已尝试使用上述代码以及
npm install --save react-native-fetch-blob
安装它 - 我正在 IOS 模拟器上尝试这个.
- I have tried importing it with both
import RNFetchBlob from 'react-native-fetch-blob'
andvar RNFetchBlob = require('react-native-fetch-blob').default
- I have tried installing it with the above code and also with
npm install --save react-native-fetch-blob
- I am trying this on the IOS emulator.
提前感谢您的帮助!
推荐答案
所以看起来模块没有导入.很明显,我知道,我只能想到几件事来帮助查看,因为该项目看起来相当流行且稳定.
So it looks like the module isn't importing. Obvious I know, I can only think of a few things to help seeing as that project looks fairly popular and stable.
我注意到您需要react-native-file-uploader"但使用react-native-fetch-blob".我假设这是一个错误.如果你还没有,你也可以试试:
I noticed that you're requiring 'react-native-file-uploader' but using 'react-native-fetch-blob'. I'm assuming this is a mistake. You could also try, if you haven't:
var RNFetchBlob = require('react-native-fetch-blob')
现在假设您正确导入它,请尝试以下操作之一,然后重新启动 x-code:
Now assuming you're correctly importing it, try one of the following and then restart x-code:
如果您还没有重新启动打包程序.我记得每次安装新模块时都必须重新启动打包程序.
If you haven't already restart the packager. I recall having to restart the packager every time I installed a new module.
如果这不起作用,请尝试安装从您的节点模块中删除它(为了安全起见)并使用可可豆荚进行安装,它将为您处理所有链接.
If that doesn't work, try installing deleting it from your node modules (just to be safe) and installing with cocoa pods which will handle all of the linking for you.
这篇关于React Native Fetch Blob - 未定义不是对象(评估'RNFetchBlob.DocumentDir')的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!