Angular push元素出错。解决方法:

网上查了很多方法,没用。通过自己的瞎折腾。

首先定义一个数组:

 private contacts:Array<{contact: string,email:string,phone:string }> = [];    //用户联系人

赋值给它:

const contcatInfo={
      contact:'',
      email:'',
      phone:''
     
    } //定义一个空的JSON数据

 然后push:

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

 

 

 

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