Typescript ionic2导入模型类实例不会导致文件错误
我正在使用Ionic2,遇到以下错误:Typescript ionic2导入模型类实例不会导致文件错误,typescript,ionic2,Typescript,Ionic2,我正在使用Ionic2,遇到以下错误: Module build failed: Error: ENOENT: no such file or directory, open "APP LOCATION"\src\Classes\SFIASkill.js'. 我强调了错误来自我的一个提供者,更具体地说,是在我实例化一个模型类的新实例时 这是我尝试使用的模型类 export class SFIASkill { ID: number; skillName: string;
Module build failed: Error: ENOENT: no such file or directory, open "APP LOCATION"\src\Classes\SFIASkill.js'.
我强调了错误来自我的一个提供者,更具体地说,是在我实例化一个模型类的新实例时
这是我尝试使用的模型类
export class SFIASkill
{
ID: number;
skillName: string;
skillCode:string;
subcategoryID: number;
Levels: Array<LevelWithDescription>;
constructor(ID: number, skillName: string, skillCode:string,subcategoryID: number)
{
this.ID = ID;
this.skillName = skillName;
this.skillCode = skillCode;
this.subcategoryID = subcategoryID;
this.Levels = new Array<LevelWithDescription>();
}
}
export class LevelWithDescription {
Description: string;
Level: SkillLevel;
constructor(description: string){
this.Description = description;
}
}
export class SkillLevel {
ID: number;
LevelName: string;
Autonomy: string;
BusinessSkills: string;
Complexity: string;
Influence: string;
constructor(id: number, levelName: string, autonomy: string, businessSkills: string, complexity: string, influence: string){
this.ID = id;
this.LevelName = levelName;
this.Autonomy = autonomy;
this.BusinessSkills = businessSkills;
this.Complexity = complexity;
this.Influence = influence;
}
}
通过对所有事件的评论,我发现正是这一行引起了问题
this.http.get('http://localhost:34417/api/Account/UserInfo', options).map(res => res.json()).subscribe(response => {
if (this.currentUser.Skills.length != 0) {
this.currentUser.Skills = new Array<SFIASkill>();
}
response.skills.forEach(element => {
let skill = new SFIASkill(element.SFIASkillID, element.Skill.SkillName, element.Skill.SkillCode, element.Skill.SkiilSubCategoryID);
skill.Levels = new Array<LevelWithDescription>();
// let level = new LevelWithDescription(element.SkillLevelDescription);
// level.Level = new SkillLevel(element.SFIASkillLevelID, element.Level.LevelName, element.Level.Autonomy, element.Level.BusinessSkills, element.Level.Complexity, element.Level.Influence);
// skill.Levels.push(level);
// this.currentUser.Skills.push(skill);
});
应用程序再次加载,但此行处于活动状态时,我收到了我提到的错误。我错过什么了吗?我看了其他问题,大多数时候人们都说导入是错误的,因为区分大小写,但是我从位置本身复制了位置的名称,所以我相信命名不是错误的
任何帮助都将不胜感激
编辑:
下面是相关文件的文件结构
src
app
assets
Classes
SFIASkill(the model class that is causing the error)
environments
pages
providers
auth-service (The service that is causing the error)
您确定导入中的相对路径正确吗?您好,@suraj我刚刚添加了一个小的文件结构代表,详细说明了两个文件之间的关系,我希望这对您有所帮助。您可能有一个打字错误
SFIASkill
和SFIASkill
。。请注意“k”的情况谢谢,我刚刚用这两个词都试过了,但仍然收到相同的错误。为了确保这不是区分大小写的问题,我尝试将文件名和相对路径更改为所有CAP,这仍然会导致错误。您确定导入中的相对路径正确吗?您好,@suraj ive刚刚添加了一个文件结构的小型代表,详细说明了两个文件之间的关系,我希望这对您有所帮助。您可能会出现打字错误SFIASkill
和SFIASkill
。。请注意“k”的情况谢谢,我刚刚用这两个词都试过了,但仍然收到相同的错误。为了确保这不是一个区分大小写的问题,我尝试更改文件名和所有CAP的相对路径,这仍然会导致错误
let skill = new SFIASkill(element.SFIASkillID, element.Skill.SkillName, element.Skill.SkillCode, element.Skill.SkiilSubCategoryID);
src
app
assets
Classes
SFIASkill(the model class that is causing the error)
environments
pages
providers
auth-service (The service that is causing the error)