Javascript Internet Explorer 9上的Webcomponents.js

Javascript Internet Explorer 9上的Webcomponents.js,javascript,polymer-1.0,google-web-component,Javascript,Polymer 1.0,Google Web Component,我正在测试google polymer在ie9上是否有效。webcomponents.min.js的第11行出现错误:“在get()和href之间”。以下是webcomponent.js文件的摘录: ... jURL.prototype = { toString: function() { return this.href; }, get href() { if (this._isInvalid) return this._url; v

我正在测试google polymer在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;
    }, ....

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

可能没有。 从他们的文件中

我们的polyfills适用于最新版本的evergreen 浏览器

下面是webcomponents.js的浏览器支持列表


您的问题是?是否有解决方法来避免此错误?我想,修复语法错误将是一个良好的开端。:)当然有
get href(){…}
不是有效的JavaScript。这是IE9能够理解的最接近的近似值是
href:function(){…}
。如果您想在IE(或任何当前浏览器)中使用此脚本,您必须将其转换为没有ES6功能的表单。您可以尝试使用ES6 transpiler,这样可以自动创建旧JS实现可以理解的源代码。您甚至可以将此步骤作为构建过程的一部分。但是,由于IE9没有它所依赖的DOM特性,所以即使它可以被IE9解析,脚本也可能无法工作。