聚合物1.0应用程序抽屉-未通过dom-if呈现时出现未捕获的TypeError [英] Polymer 1.0 App-Drawer - Uncaught TypeError when not rendered via dom-if

查看:85
本文介绍了聚合物1.0应用程序抽屉-未通过dom-if呈现时出现未捕获的TypeError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

仅向成员显示菜单 我有这段代码

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.

错误:

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

推荐答案

<app-drawer-layout>中的布局逻辑

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.

您所看到的错误的一种解决方法是通过在<app-drawer>内移动dom-if来创建一个空的<app-drawer>:

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>

不幸的是,这将在用户登录之前创建一个空白抽屉,但这可能对您的应用程序是可接受的. codepen

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

这篇关于聚合物1.0应用程序抽屉-未通过dom-if呈现时出现未捕获的TypeError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆