我收到了一个带有这种形式的json对象:
[{
"id": 1,
"url": "url 1",
"name": "Luke Skywalker",
"height": 172,"weight": 77,
"Cars":["car1","car2"]
}]
我创建了一个数据模型
**Person.ts**
id: number;
url: string;
name: string;
height: number;
weight: number;
cars:Car[];
Car.ts:
id_car:number;
name_car:string;
info_car:string;
但不接受在person.ts中添加此行(cars:Car [])
那我该怎么办?
答案 0 :(得分:0)
尝试使用此: 的 Person.ts 强>
id: number;
url: string;
name: string;
height: number;
weight: number;
cars: {
type: [{
type: String,
}],
}