我正在做这个教程,我使用的代码或版本似乎有一些问题。
我正在尝试导入常量。但是,它找不到常量。数组下有红线:arrGender;、arrOccupation:数组等
//3. import all constants
import {
Occupations,
JobTypes,
Genders,
Hobbies,
MartialStatuses,
ResidentTypes,
Qualifications
} from './constData';
export class PersonalInformationComponent implements OnInit {
// 7a. Define the properties for databinding
person: Person;
persons: Array<Person>;
arrGender: Array;
arrOccupation: Array<Occupations>;
arrJobType: Array<JobTypes>;
arrQualification: Array<Qualifications>;
arrHobbies: Array<Hobbies>;
arrMartialStatus: Array<MartialStatuses>;
arrResidentialType: Array<ResidentTypes>;
canChange: boolean;
canEdit: boolean;
tableHeaders: Array;
constructor(private pServ: PersonalInfoService) {
this.canChange = false;
this.canEdit = false;
this.tableHeaders = new Array();
this.person = new Person();
this.persons = new Array();
this.arrGender = new Array();
}发布于 2018-02-17 12:44:09
//3. import all constants
import {
Occupations,
JobTypes,
Genders,
Hobbies,
MartialStatuses,
ResidentTypes,
Qualifications
} from './constData';
export class PersonalInformationComponent implements OnInit {
// 7a. Define the properties for databinding
person: Person;
persons: Array<Person>;
// You forgot to add the type to the Array here...
arrGender: Array<Gender>;
arrOccupation: Array<Occupations>;
arrJobType: Array<JobTypes>;
arrQualification: Array<Qualifications>;
arrHobbies: Array<Hobbies>;
arrMartialStatus: Array<MartialStatuses>;
arrResidentialType: Array<ResidentTypes>;
canChange: boolean;
canEdit: boolean;
// You forgot to add the type to the Array here...
tableHeaders: Array<string>;
constructor(private pServ: PersonalInfoService) {
this.canChange = false;
this.canEdit = false;
this.tableHeaders = new Array();
this.person = new Person();
this.persons = new Array();
this.arrGender = new Array();
}
}
https://stackoverflow.com/questions/48833922
复制相似问题