问题
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