3
我想用Angular2編寫Webstorm上的Web應用程序。做這件事我很新。我正在嘗試角網站Angular.IO上的教程。類型'MyObject'中缺少屬性'prototype'
當我嘗試製作人可點擊的列表時,它不起作用。
export class PersonComponent {
persons = MYPERSONS;
selectedPersons = Person;
onSelect(person: Person): void {
this.selectedPerson = person; // here is the error on "this.selectedPerson"
}
}
const MYPERSONS: Person[] = [
{id:0, firstName: 'First', lastName: 'Firstly', creationData: 1},
{id:1, firstName: 'Second', lastName: 'Test', creationData:10},
{id:2, firstName: 'Third', lastName: 'Candidate', creationData:5}
];
export class Person {
id: number;
firstName: string;
lastName: string;
creationData: any;
}
我得到以下錯誤:
Type 'Person' is not assignable to type 'typeof Person'. Property 'prototype' is missing in type 'Person'.
是什麼意思?我無法在互聯網上找到這個錯誤。這可能是什麼什麼,我沒有對代碼看到的,因爲我的一些經驗
天啊!謝謝。這太微不足道了! – TYL
@TubaYlm,太棒了,別忘了你可以接受我的回答:) –
如果你有上面的錯誤只是檢查=和: – Khuzema