簡単な質問:いくつかの多次元プロパティを持つオブジェクトを作成したいと思います。Typescript:多次元プロパティを持つオブジェクトを作成する
ユーザークラスには、性別、生年月日、身長などのプロパティがあります。
また、ユーザが現在の日付で新しい重みを追加できる、多次元の重みのプロパティ。ここ
interface weightData {
date: Date;
weight: number;
}
export class UserData {
sex: string;
location:string;
fokus:string;
birthdate:Date;
weight:Array<weightData> = [];
height:number;
constructor(sex:string, location:string, fokus:string, birthdate:Date, height:number, weight:number) {
let currentDate: Date = new Date();
this.sex = sex;
this.location = location;
this.fokus = fokus;
this.birthdate = birthdate;
this.height = height;
this.weight.push(
date: currentDate, //dont work
weight: 31 // dont work
);
}
}
私の2つの問題点:
1:いただきましたコンストラクタのために右の構文?
2:「ウェイト」に新しい値を追加する方法を作成するにはどうすればよいですか?
ありがとうございます。