使用VS模板创建的Angular 2 ASP.NET Core应用程序中的Polyfills.ts,会丢失吗? [英] Polyfills.ts in my Angular 2 ASP.NET Core application created using VS template, are they missing?

查看:49
本文介绍了使用VS模板创建的Angular 2 ASP.NET Core应用程序中的Polyfills.ts,会丢失吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Angular开发的新手,并且使用Visual Studio 2017 Professional模板开始使用ASP.Net Core创建Angular 2应用程序:

I'm newbie in Angular development and I'm using Visual Studio 2017 Professional template to start creating an Angular 2 application with ASP.Net Core:

我的问题是该应用程序无法在Internet Explorer 11上运行,并且搜索后发现我必须取消对 polyfills 文件中的某些内容的注释.

My problem is that the app doesn't run on Internet Explorer 11 and searching I have found that I have to uncomment something on polyfills file.

我在 D:\ MyProjects \ NetCore \ AngularWebApplication \ AngularWebApplication \ node_modules \ graceful-fs \ polyfills.js 上找到了它,但是它没有期望的相同内容(例如在此 SO答案中显示.

I have found it on D:\MyProjects\NetCore\AngularWebApplication\AngularWebApplication\node_modules\graceful-fs\polyfills.js but it doesn't have the same content that expected (like the ones show in this SO answer).

使用VS模板是一个好主意,还是我可以使用Empty模板并将Angular应用添加到其中?

Is it a good idea to use VS template or maybe I can use the Empty template and add the Angular app to it?

推荐答案

我遇到了同样的问题-幸运的是,修复很简单.

I came across this same problem - and fortunately the fix is dead simple.

将您的 polyfills.ts 文件与 boot.browser.ts 文件放在同一目录中(我运行了 ng新的测试应用在临时目录中执行命令以获取最新文件),然后在 boot.browser.ts 文件顶部添加以下行:-

Put your polyfills.ts file in the same directory as the boot.browser.ts file (I ran an ng new test-app command in a temp directory just to get the latest files), than add the following line at the top of the boot.browser.ts file:-

import'./polyfills';

然后,您必须删除 polyfills.ts 文件中的注释掉的位,以包含要支持的浏览器所需的导入,并运行和 npm install 命令(如 polyfills.ts 中的行注释中所指定).

You'll then have to remove the commented out bits in polyfills.ts file to include the required imports for the browsers you want to support, and also run and npm install commands that are required (as specified in the comments on the lines in polyfills.ts).

那应该为您解决IE11问题.

That should fix the IE11 problem for you.

您提到使用Empty模板,然后使用 ng new 创建应用程序,但这并不是一件容易的事,要使其在Visual Studio中运行(和调试),因此最好使用VS如果您沿那条路线走,请输入代码.如果可以部署到支持 .net core node.js 的环境,那么最好使用.net core Angular模板.

You mentioned using an Empty template then creating an app using ng new, but it's not a trivial task getting it (and debugging) working in Visual Studio, so you're probably better off using VS Code if you're going down that route. If you can deploy to an environment that supports .net core and node.js, then you're probably better off using the .net core Angular template.

这篇关于使用VS模板创建的Angular 2 ASP.NET Core应用程序中的Polyfills.ts,会丢失吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆