Angular 2最终版本Visual Studio-无法确定模块名称,module.id传递的路径不正确/导致404
我刚刚升级到Angular 2最终版本(我使用的是Visual Studio 2015和TypeScript 1.8),注意到我的组件中的行Angular 2最终版本Visual Studio-无法确定模块名称,module.id传递的路径不正确/导致404,angular,Angular,我刚刚升级到Angular 2最终版本(我使用的是Visual Studio 2015和TypeScript 1.8),注意到我的组件中的行moduleId:module.id现在有了红色的扭曲下划线,并说找不到名称“module” 在Chrome的网络选项卡中,我看到templateUrl和styleURL路径都不正确 这是我的工作组件: @Component({ selector: 'dashboard', moduleId: module.id, templateU
moduleId:module.id
现在有了红色的扭曲下划线,并说找不到名称“module”
在Chrome的网络选项卡中,我看到templateUrl
和styleURL
路径都不正确
这是我的工作组件:
@Component({
selector: 'dashboard',
moduleId: module.id,
templateUrl: 'dashboard.component.html',
styleUrls: ['dashboard.component.css'],
styles: ['.chart {display: block; width: 100%;} .title.handle{background-color:transparent;}']
})
**但是当我删除行moduleId:module.id
时,我得到一个404错误,因为它正在查找:
http://localhost:56159/dashboard.component.css
和http://localhost:56159/dashboard.component.html
任何帮助都将不胜感激
谢谢你试试这个,把这两个文件的路径放在前面
@Component({
selector: 'dashboard',
templateUrl: './dashboard.component.html',
styleUrls: ['./dashboard.component.css'],
styles: ['.chart {display: block; width: 100%;} .title.handle{background-color:transparent;}']
})
您将需要引用节点定义typescript文件。 如您所见,模块在第70行定义
declare var module: NodeModule;
相同的结果
styleURL:['./dashboard.component.css'],
导致http://localhost:56159/dashboard.component.css
能否尝试升级您的打字脚本版本?根据Angle文档,这是理想的行为。您是否也升级了angular cli?@EduardoDennis我没有使用angular clicli@SefaÜmitOray我会试试,尽管其他开发人员也在使用这台机器,所以我不能只是暂时试用-我如何在Angular 2最终版本中引用它?你应该通过typings definition manager安装它。运行npm install typings
会再次安装打字,但不会影响moduleId:module.id,
typings install dt~节点--save--global下的红色波形