Polymer2混合更新错误:'未捕获TypeError:类扩展值undefined不是构造函数或null'

时间:2017-09-22 15:25:26

标签: polymer upgrade polymer-2.x

问题

我已开始将聚合物PWA升级到2.0版聚合物。 docs建议将大项目升级到聚合物1.8版本,将元素升级到2.0混合风格。我也这样做,但我得到了以下错误

未捕获TypeError:类扩展值undefined不是构造函数或null

有人可以帮助我解决这个问题,而且我不知道混合风格的元素是什么意思是2.0还是别的什么?

提前致谢。

我的元素(已更新)

<link rel="import" href="../../bower_components/polymer/polymer.html">
<link rel="import" href="../../bower_components/paper-material/paper-material.html">

<dom-module id="account-analytics">
  <template>
  <style >
 .flex{
  display: flex;
   width: 100%;
   align-items: center;
 }
    .flexChild{
      flex-grow: 1;
      text-align: center;
      flex-basis: 40px;
    }

  </style>

    <iron-ajax auto
               id="accountAnalytics"
               url="/napi/accountanalytics"
               handle-as="json"
               last-response="{{analytics}}"
               loading="{{analyticsLoading}}"
               debounce-duration="1000">

    </iron-ajax>
    <div style="font-size: 25px;font-weight: bold;display: none;padding-top: 2%;padding-left: 2%;padding-bottom: 2%" id="analyticsHead">eGlu Today</div>
    <div class="flex">
      <div class="flexChild"><b>Rules</b></div>
      <div class="flexChild"><b>Scenes</b></div>
      <div class="flexChild"> <i class="material-icons">linked_camera</i></div>
      <div class="flexChild"><i class="material-icons">android</i></div>
      <div class="flexChild"><img src="../../images/apple_logo_200px.jpeg" style="width: 30px;padding-bottom: 5px"></div>
    </div>
    <div class="flex">
      <div class="flexChild">{{analytics.ruleCount}}</div>
      <div class="flexChild">{{analytics.sceneCount}}</div>
      <div class="flexChild">{{analytics.cameraCount}}</div>
      <div class="flexChild">{{analytics.androidInstallations}}</div>
      <div class="flexChild">{{analytics.iosInstallations}}</div>
    </div>
  </template>
</dom-module>
<script>
  class accountAnalytics extends Polymer.Element{
   static get is(){return 'account-analytics';}
      static get properties(){
     return{
       hubId: {
         type: String,
         value: '7e-f2-ca-ab-40-34-34-95',
         notify: true
       },
       analyticsLoading:{
         type:Boolean,
         notify:true
       },
       analytics:Object,
       customerId:{
         type:String,
         value:'',
         observer:'emailChanged'
       },
       integratorOptions:Boolean,
       refreshCustomer:{
         type:Boolean,
         value:false,
         notify:true,
         observer:'_refreshCustomer'
       }
     };
      }

        constructor() {
           super();
        }

        emailChanged() {
          if(this.customerId=='')
            this.$.analyticsHead.style.display='block';
          this.fireAnalytics();
        }
        _refreshCustomer() {
          this.fireAnalytics();
          this.refreshCustomer=false;
        }
        ready(){
          super.ready();
          this.fireAnalytics();
        }
      fireAnalytics(){
        if(this.customerId==undefined)
          return;
        var t= Date.now();
        var p = this.getCookie('token');
        this.$.accountAnalytics.headers={"token":p};
        this.$.accountAnalytics.params={"customerId":this.customerId,"t":t};
//        this.$.accountAnalytics.generateRequest();
      }
        getCookie(cname) {
          var name = cname + "=";
          var ca = document.cookie.split(';');
          for(var i = 0; i < ca.length; i++) {
            var c = ca[i];
            while (c.charAt(0) == ' ') {
              c = c.substring(1);
            }
            if (c.indexOf(name) == 0) {
              return c.substring(name.length, c.length);
            }
          }
          return "";
        }


  }
  customElements.define(accountAnalytics.is, accountAnalytics);

</script>

0 个答案:

没有答案