Angular 2(4),Webpack站点将无法在IE 11中的服务器上运行

dok*_*ker 4 internet-explorer angularjs webpack angular

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

未处理的Promise拒绝:无法加载函数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 :;任务: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 undefined

对我来说意味着什么的唯一部分是'api /'是完全错误的,并且我已经仔细检查过该组件,它清楚地说:

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

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

我的webpack.config.js很简单:

/// <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));
      }

};
Run Code Online (Sandbox Code Playgroud)

这里发生了什么?

kab*_*hya 7

顺便说一下,我遇到了同样的情况.我迁移到使用webpack 2后,我的应用程序无法在IE 11中运行.

我只是把这些看起来好像现在正在运作.

<script src="https://cdnjs.cloudflare.com/ajax/libs/es5-shim/4.5.7/es5-shim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/es5-shim/4.5.7/es5-sham.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.34.2/es6-shim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.34.2/es6-sham.min.js"></script>
Run Code Online (Sandbox Code Playgroud)

检查一下:https://github.com/es-shims/es5-shim#example-of-applying-es-compatability-shims-in-a-browser-project

注意:如果你只关心IE 11,你可以跳过前两个es5垫片.但如果您确实需要支持浏览器<= IE 11,则可能需要它们.