簡體   English   中英

類型的參數不能分配給類型的參數。對象文字只能指定已知的屬性

[英]Argument of type is not assignable to parameter of type .Object literal may only specify known properties

我將數據插入Firebase數據庫中,一旦提交提交的表單數據成功但在TypeScript文件中卻收到錯誤,可以告訴我我做錯了什么嗎? 在代碼中。

這是我的registerpage.ts代碼

regPhotographer = {} as RegPhotographer;

  regPhotographerRef$: AngularFireList<RegPhotographer[]>;

  constructor( private db: AngularFireDatabase, public router: Router ) { 
    this.regPhotographerRef$ = this.db.list('register');
  }

 addPhotographer(regPhotographer: RegPhotographer): void{
        this.regPhotographerRef$.push({
          fname: this.regPhotographer.fname,<!--The Error Line-->
          lname: this.regPhotographer.lname,
          location: this.regPhotographer.location,
          area: this.regPhotographer.area,
          amount: this.regPhotographer.amount,
          pin: this.regPhotographer.pin 
        });

這是我的registeruser.ts頁面代碼。

export interface RegPhotographer {
    fname: string;
    lname: string;
    location: string;
    area: string;
    amount: string;
    pin: string;
}

看來您的AngularFireListAngularFireList類型, RegPhotographer不是RegPhotographer[]類型。 它已經是列表,而不是數組列表。

regPhotographerRef$: AngularFireList<RegPhotographer>;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM