Polymer 1.0 App-Drawer - Uncaught TypeError when not rendered via dom-if

蓝咒 提交于 2020-01-07 02:01:32

问题


Displaying the menu only to members I've got this bit of code

<app-drawer-layout fullbleed>

  <!-- Drawer content -->
  <template is="dom-if" if="{{signedIn}}">
   <app-drawer>
   ....

This displays the menu only when users are logged in to the application. It works fine but is there anyway to remove the error it causes in the console.

error:

polymer-mini.html:2046 Uncaught TypeError: Cannot read property 'getWidth' of undefined

回答1:


The layout logic in <app-drawer-layout> requires an <app-drawer> to determine the appropriate container margins. I don't see an option to disable that logic.

A workaround for the error you're seeing is to create an empty <app-drawer> by moving the dom-if inside the <app-drawer>:

<app-drawer>
  <template is="dom-if" if="{{signedIn}}">
    ...
  </template>
</app-drawer>

This unfortunately would create a blank drawer before the user signs in, but maybe this is acceptable for your app. codepen



来源:https://stackoverflow.com/questions/37799018/polymer-1-0-app-drawer-uncaught-typeerror-when-not-rendered-via-dom-if

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!