'{ query: { limitToLast: number; } 类型的参数orderByKey:布尔值;};}' 不能分配给'FirebaseListFactoryOpts'类型的参数 [英] Argument of type '{ query: { limitToLast: number; orderByKey: boolean; }; }' is not assignable to parameter of type 'FirebaseListFactoryOpts'
本文介绍了'{ query: { limitToLast: number; } 类型的参数orderByKey:布尔值;};}' 不能分配给'FirebaseListFactoryOpts'类型的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
user: any;
chatMessages: FirebaseListObservable<ChatMessage[]>;
chatMessage: ChatMessage;
userName: Observable<string>;
constructor(
public db: AngularFireDatabase,
public afAuth: AngularFireAuth,
) {
this.afAuth.authState.subscribe(auth => {
if (auth !== undefined && auth !== null){
this.user = auth;
}
});
}
sendMessage(msg: string){
const timestamp = this.getTimeStamp();
const email = this.user.email;
this.chatMessages = this.getMessages();
this.chatMessages.push({
message: msg,
timeSent: timestamp,
userName: this.userName,
email: email});
}
getMessages(): FirebaseListObservable<ChatMessage[]>{
return this.db.list('/messages', {
query: {
limitToLast: 25,
orderByKey: true
}
});
}
我正在使用 angular 和 firebase 制作一个网络聊天应用程序,然后我收到了这个错误,即查询不是 FireBaseListFactoryOpts 的兼容类型.如果有人可以,请帮忙.
i was making a web chat app using angular and firebase then i got this error that query is not a compatible type of FireBaseListFactoryOpts. please help if anyone can.
推荐答案
getMessages(): AngularFireList<ChatMessage[]> {
return this.db.list('messages',ref => ref.orderByKey().limitToLast(25));
}
现在使用这个代替那个,这会起作用,因为 FireBaseListObservable 被 AngularFirelist 替换了.
use this instead of that now this will work because FireBaseListObservable is replaced with AngularFirelist.
这篇关于'{ query: { limitToLast: number; } 类型的参数orderByKey:布尔值;};}' 不能分配给'FirebaseListFactoryOpts'类型的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文