我已经安装了@ react-native-firebase / app和@ react-native-firebase / storage 以下是我的package.json:
"dependencies": {
"@react-native-firebase/app": "^6.0.4",
"@react-native-firebase/storage": "^6.0.4",
"firebase": "^5.11.1",
...这是我需要@ react-native-firebase / storage
的地方import rnFb from '@react-native-firebase/storage';
..这是我用来上传图片的函数:
uploadImage = localUri =>
new Promise((resolve, reject) => {
const localUri2 = Platform.OS === 'ios' ? localUri.replace('file://', '') : localUri;
const fbUri = Firebase.storage().ref();
rnFb.storage().ref(localUri2).putFile(fbUri)
.then(() => { resolve(); })
.catch((e) => { reject(e); });
});
我收到的错误是:
TypeError: _storage.default.storage is not a function
有人可以帮忙吗? 谢谢!!
答案 0 :(得分:0)
尝试以下
import storage from '@react-native-firebase/storage';
...
storage().ref(localUri2)
...
或
import { firebase } from '@react-native-firebase/storage';
...
firebase.storage().ref(localUri2)
...