我正在Visual Studio 2017中使用ASP.NET Core
运行一个Angular
应用。不幸的是,每当我运行该项目时,它就会在浏览器中显示以下消息:
Cannot GET /
经过几个小时的谷歌搜索(Sample Link),我尝试了以下操作,并添加了tsconfig.json文件:
"lib": [ "es5", "es6", "es2017", "dom" ]
在我的情况下,这之前是这样的:
"lib": [ "es2017" ]
尽管该项目构建成功,但几乎没有以下错误:
Severity Code Description Project File Line Suppression State
Error TS2583 (TS) Cannot find name 'Set'. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later. ASP.NETCoreWithAngular C:\Users\Amit's-PC\source\repos\ASP.NETCoreWithAngular\ASP.NETCoreWithAngular\ClientApp\node_modules\@angular\common\src\directives\ng_class.d.ts 48 Active
Severity Code Description Project File Line Suppression State
Error TS2583 (TS) Cannot find name 'Map'. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later. ASP.NETCoreWithAngular C:\Users\Amit's-PC\source\repos\ASP.NETCoreWithAngular\ASP.NETCoreWithAngular\ClientApp\node_modules\@angular\core\src\change_detection\differs\default_keyvalue_differ.d.ts 24 Active
Severity Code Description Project File Line Suppression State
Error TS2585 (TS) 'Promise' only refers to a type, but is being used as a value here. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later. ASP.NETCoreWithAngular C:\Users\Amit's-PC\source\repos\ASP.NETCoreWithAngular\ASP.NETCoreWithAngular\ClientApp\node_modules\rxjs\Observable.d.ts 58 Active
我在这里错过了什么吗?任何想法将不胜感激。
答案 0 :(得分:1)
从错误消息中您可能会发现,JavaScript
的默认配置很可能是es5
或es2015
以下的任何其他配置。意味着您正在尝试使用es2015
功能,并且编译器现在允许您使用。检查您的IDE配置,并确保您的JavaScript
配置至少设置为es2015
答案 1 :(得分:0)
基于您的错误,我认为您的应用程序的MVC部分中存在路由问题。您应该确保正确配置了默认路由。
以下文章在此处提供了一些有用的指导。
https://knightcodes.com/angular2/2017/01/05/angular-2-routes-with-asp-net-mvc.html