我正在编写本教程,似乎代码或我正在使用的版本存在一些问题。
我正在尝试导入常量。 但是,它没有找到常量。下面有红线 arrGender:Array;, 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();
}
答案 0 :(得分:0)
//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();
}
}