我有一个Hero和一个地址模型类,Hero的一个属性是它的地址,它由以下组成:街道,城市......在具体的模型源类中指定它的正确方法是什么? / p>
hero.ts:
import {Address} from './address';
export class Hero {
id: number;
name: string;
powers: string [];
address: Address;
}
address.ts:
export class Address {
street: string;
street2: string;
city: string;
state: string;
}
模拟heroes.ts:
import {Hero} from './hero';
export var HEROES: Hero[] = [
{"id": 11, "name": "Mr. Nice", "powers" : ['nice', 'helpful'], "address" : ("a", "b", "c", "d")},
{"id": 12, "name": "Narco", "powers" : ['nice', 'helpful'], "address" : ("a", "b", "c", "d")}
];
当我跑“npm start”时出错:
app / mock-heroes.ts(3,12):错误TS2322:输入'{“id”:number; “name”:string; “powers”:string []; “地址”:字符串; } []'不能分配给'Hero []'。 输入“{”id“:number; “name”:string; “powers”:string []; “地址”:字符串; }'不能指定为'英雄'类型。 属性“地址”的类型不兼容。 类型“字符串”不能指定为“地址”类型。
答案 0 :(得分:3)
非常简单:
ERROR: invalid input syntax for integer: "Total MDs"
CONTEXT: COPY tampadocs, line 1, column totalmd: "Total MDs"