打字稿错误:属性 .ref 在类型 'AngularFireStorageModule' 上不存在
Error in typescript: property .ref does not exist on type 'AngularFireStorageModule'
我正在尝试使用 Ionic 中的 AngularFire 将图像上传到 firebase,但我一直收到错误 'Property '.ref' does not exist on type 'AngularFireStorageModule'.'
。
进口:
import { AngularFireAuth } from 'angularfire2/auth';
import { AngularFirestore, AngularFirestoreCollection } from 'angularfire2/firestore';
import { AngularFireStorageModule } from 'angularfire2/storage';
import * as firebase from 'firebase/app';
import { enableLogging } from '@firebase/database-types';
.ref 出错
for(var i = 0; i < this.imagePaths.length; i++){
console.log("Adding photo's" + this.imagePaths[i]);
const filePath = 'images/' + this.docRef + '/';
const ref = this.storage.ref(filePath);
const task = ref.put(this.imagePaths[i]).then((snapshot) => {
console.log('Uploaded an image!');
});
}
错误发生在const ref = this.storage.ref(filePath);
行
有人知道为什么这行不通吗?我在网上搜索,但所有教程都按照我所做的方式进行了所有操作。
import { AngularFireStorage } from 'angularfire2/storage';
constructor(private storage: AngularFireStorage)
uploadFile(file){
const filePath = 'images/' + this.docRef + '/';
const task = this.storage.upload(filePath, file);
task.percentageChanges().subscribe(per => {
console.log(per);
});
task.downloadURL().subscribe(url => {
console.log(url);
}
}
我正在尝试使用 Ionic 中的 AngularFire 将图像上传到 firebase,但我一直收到错误 'Property '.ref' does not exist on type 'AngularFireStorageModule'.'
。
进口:
import { AngularFireAuth } from 'angularfire2/auth';
import { AngularFirestore, AngularFirestoreCollection } from 'angularfire2/firestore';
import { AngularFireStorageModule } from 'angularfire2/storage';
import * as firebase from 'firebase/app';
import { enableLogging } from '@firebase/database-types';
.ref 出错
for(var i = 0; i < this.imagePaths.length; i++){
console.log("Adding photo's" + this.imagePaths[i]);
const filePath = 'images/' + this.docRef + '/';
const ref = this.storage.ref(filePath);
const task = ref.put(this.imagePaths[i]).then((snapshot) => {
console.log('Uploaded an image!');
});
}
错误发生在const ref = this.storage.ref(filePath);
有人知道为什么这行不通吗?我在网上搜索,但所有教程都按照我所做的方式进行了所有操作。
import { AngularFireStorage } from 'angularfire2/storage';
constructor(private storage: AngularFireStorage)
uploadFile(file){
const filePath = 'images/' + this.docRef + '/';
const task = this.storage.upload(filePath, file);
task.percentageChanges().subscribe(per => {
console.log(per);
});
task.downloadURL().subscribe(url => {
console.log(url);
}
}