網上查了很多方法,沒用。通過自己的瞎折騰。
首先定義一個數組:
private contacts:Array<{contact: string,email:string,phone:string }> = []; //用戶聯繫人
賦值給它:
const contcatInfo={
contact:'',
email:'',
phone:''
} //定義一個空的JSON數據
然後push:
const index = this.contacts.push(contcatInfo);