Angular 2(4),Webpack网站无法在IE 11中的服务器上运行 [英] Angular 2 (4), Webpack site won't work on server in IE 11

查看:70
本文介绍了Angular 2(4),Webpack网站无法在IE 11中的服务器上运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在angular或webpack中是否有针对IE的特殊开关,因为当我在 http://localhost:port/上运行网站时.另外,当我在Edge或Chrome上的服务器 http://server.domain/mysite/上运行它时,作品.但是,当我在IE 11(兼容模式设置为11)上打开它时,在控制台中收到以下错误:

Is there some special switch for IE in angular or webpack because when I run my site on http://localhost:port/ it works. Also, when I run it on server http://server.domain/mysite/ on Edge or Chrome it works. But when I open it on IE 11 (with compatibility mode set to 11) I receive a following error in console:

未处理的承诺拒绝:无法加载函数t(t){var e = this; this.http = t,this.getItems = function(){e.results = null,e.http.get(" api /app/components/my-items.component.html;区域:;任务:Promise.then;值:无法加载函数t(t){var e = this; this.http = t, this.getItems = function(){e.results = null,e.http.get(" api /app/components/my-items.component.html未定义

Unhandled Promise rejection: Failed to load function t(t){var e=this;this.http=t,this.getItems=function(){e.results=null,e.http.get("api/app/components/my-items.component.html ; Zone: ; Task: Promise.then ; Value: Failed to load function t(t){var e=this;this.http=t,this.getItems=function(){e.results=null,e.http.get("api/app/components/my-items.component.html undefined

对我而言唯一有意义的部分是'api/'是完全错误的,并且我已经仔细检查了该组件,并清楚地表明:

The only part that means anything to me is that 'api/' is plain wrong and that I've double checked the component and it clearly says:

@Component({
    selector: 'my-items',
    templateUrl: 'app/components/my-items.component.html'
})
export class MyItemsComponent implements OnInit { ...

在整个解决方案中(包括c#,ts,css,html和js文件),没有一个短语"api/app"出现

There is not a single occurrence of phrase 'api/app' in the whole solution (including c#, ts, css, html and js files)

我的webpack.config.js很简单:

My webpack.config.js is simple:

/// <binding ProjectOpened='Watch - Development' />
var path = require('path');
var webpack = require('webpack');
var console = require('console');


module.exports = {
    context: path.join(__dirname, 'wwwroot'),
    //vendor: ['libs/@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js'],
    entry: './app/main.js',
    output: {
        path: path.join(__dirname, 'wwwroot/built'),
        filename: '[name].bundle.js',
    },
    plugins: [
            //new webpack.optimize.CommonsChunkPlugin("vendor", "vendor.bundle.js"),
            // split vendor js into its own file
    new webpack.optimize.CommonsChunkPlugin({
      name: 'vendor',
      minChunks: function (module, count) {
          // any required modules inside node_modules are extracted to vendor
          var path = module.resource.replace(/\\/g, '/');

          return (/\.js$/.test(path) && (path.indexOf('node_modules/') >= 0 || path.indexOf('libs/') >= 0));
      }

};

这是怎么回事?

推荐答案

我在使用2.0.0-rc.1和webpack时遇到了同样的问题.在阅读了一些问题之后,对我来说,解决方案是在索引中包括以下脚本浏览器为IE时的.html:

I got stuck with the same problem using 2.0.0-rc.1 and webpack. After reading some issues, the solution for me was to include the following scripts on my index.html when the browser is IE:

es6-shim.min.js
system-polyfills.js
shims_for_IE.js

前两个可以在node_modules中找到,我从

The first two can be found inside node_modules, and I downloaded the third from here.

这篇关于Angular 2(4),Webpack网站无法在IE 11中的服务器上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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