Angular push元素出錯。解決方法:

網上查了很多方法,沒用。通過自己的瞎折騰。

首先定義一個數組:

 private contacts:Array<{contact: string,email:string,phone:string }> = [];    //用戶聯繫人

賦值給它:

const contcatInfo={
      contact:'',
      email:'',
      phone:''
     
    } //定義一個空的JSON數據

 然後push:

 const index = this.contacts.push(contcatInfo);

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章