【问题标题】:Webcomponents.js on Internet Explorer 9Internet Explorer 9 上的 Webcomponents.js
【发布时间】:2015-06-17 03:56:15
【问题描述】:

我正在测试谷歌聚合物是否适用于 ie9。 webcomponents.min.js 的第 11 行出现错误,在 get() 和 href 之间需要“:”。以下是 webcomponent.js 文件的摘录:

...
jURL.prototype = {
    toString: function() {
      return this.href;
    },
    get href() {
      if (this._isInvalid) return this._url;
      var authority = "";
      if ("" != this._username || null != this._password) {
        authority = this._username + (null != this._password ? ":" + this._password : "") + "@";
      }
      return this.protocol + (this._isRelative ? "//" + authority + this.host : "") + this.pathname + this._query + this._fragment;
    }, ....

是否有避免此错误的解决方法?

【问题讨论】:

  • 你的问题是?
  • 是否有避免此错误的解决方法?
  • 好吧,我想修复语法错误将是一个好的开始。 :)
  • 当然有。 get href() { ... } 不是有效的 JavaScript。这是一个ES6 getter,IE9 能理解的最接近的近似值是href: function () { ... }。如果你想在 IE(或者任何当前的浏览器,真的)中使用这个脚本,你必须把它翻译成没有 ES6 特性的表单。
  • 您可以尝试使用像babel.js 这样的 ES6 转译器,它可以自动创建旧 JS 实现可以理解的源代码。您甚至可以将此步骤作为构建过程的一部分。但是即使它可以被 IE9 解析,脚本也可能不起作用,因为 IE9 没有它所依赖的 DOM 功能。

标签: javascript polymer-1.0 google-web-component


【解决方案1】:

可能不会。 从他们的文档中

我们的 polyfill 旨在在最新版本的 evergreen 中工作 浏览器

这是 webcomponenets.js 的浏览器支持矩阵

https://github.com/WebComponents/webcomponentsjs#browser-support

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-06-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-25
    • 1970-01-01
    • 2012-07-29
    • 2023-03-18
    相关资源
    最近更新 更多