Angular 财产';firestore&x27;不存在于类型';Firebase';
我正在尝试获取创建文档的准确时间。 为此,我使用以下导入Angular 财产';firestore&x27;不存在于类型';Firebase';,angular,firebase,ionic-framework,google-cloud-firestore,Angular,Firebase,Ionic Framework,Google Cloud Firestore,我正在尝试获取创建文档的准确时间。 为此,我使用以下导入 import { Firebase } from '@ionic-native/firebase/ngx'; import { AngularFirestore } from '@angular/fire/firestore'; import { AngularFirestore } from '@angular/fire/firestore'; 我的构造函数如下 constructor(private aF: AngularFireS
import { Firebase } from '@ionic-native/firebase/ngx';
import { AngularFirestore } from '@angular/fire/firestore';
import { AngularFirestore } from '@angular/fire/firestore';
我的构造函数如下
constructor(private aF: AngularFireStore, private firebase: Firebase, private cS: CartService, private ui: UiService){}
下面是我试图添加时间戳的方法
checkout2() {
const pickup = this.pickup;
const deliveryname = this.deliveryname;
const location = this.location;
const note = this.note;
const deliverystate = this.deliverystate;
const cart = this.cS.getCart();
const total = this.getTotal();
const uid = this.aS.getInfo();
return new Promise<any>((resolve, reject) => {
this.aF.collection('/ordenes').add({
cart,
pickup,
location,
deliveryname,
createdAt: this.firebase.firestore.Timestamp.fromDate(new Date()),
note,
total,
deliverystate,
uid
})
.then(
(res) => {
resolve(res);
this.cS.cleanCart();
this.cS.cleanItemCount();
this.close();
},
err => reject(err)
);
});
}
checkout2(){
const pickup=this.pickup;
const deliveryname=this.deliveryname;
const location=this.location;
const note=this.note;
const deliverystate=this.deliverystate;
const cart=this.cS.getCart();
const total=this.getTotal();
const uid=this.aS.getInfo();
返回新承诺((解决、拒绝)=>{
此.aF.collection('/ordenes').add({
运货马车
改善
位置,
送货名称,
createdAt:this.firebase.firestore.Timestamp.fromDate(new Date()),
注意,
全部的
交付状态,
液体
})
.那么(
(res)=>{
决议(res);
this.cS.cleanCart();
this.cS.cleanItemCount();
这个。关闭();
},
err=>拒绝(err)
);
});
}
我得到一个错误,上面写着:
类型“Firebase”上不存在属性“firestore”
我不知道我是否导入了错误的库,提前感谢您的帮助 您使用的是以下软件包
@ionic native/firebase/ngx
,其中不包含任何与firestore
相关的内容。您可以在以下链接中找到包的api:
您需要初始化firestore
,然后可以使用上述方法,有关更多信息,请查看此处: