加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

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

发布时间:2020-12-17 17:56:43 所属栏目:安全 来源:网络整理
导读:在角度或webpack中是否有一些特殊的IE开关,因为当我在 http://localhost:port/上运行我的网站时,它可以工作.此外,当我在Edge或Chrome上的服务器 http://server.domain/mysite/上运行它时,它可以工作.但是当我在IE 11上打开它(兼容模式设置为11)时,我在控制台
在角度或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 { ...

整个解决方案中没有出现短语’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));
      }

};

这里发生了什么?

解决方法

我使用2.0.0-rc.1和webpack遇到了同样的问题.在阅读了一些 issues之后,我的解决方案是在浏览器是IE时在我的index.html上包含以下脚本:

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

前两个可以在node_modules中找到,我从here下载了第三个.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读