聚合物导航抽屉面板上的调用功能

编程入门 行业动态 更新时间:2024-10-26 14:32:33
本文介绍了聚合物导航抽屉面板上的调用功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我被困住了.我在玩聚合物,但无法管理抽屉面板上的togglePanel函数,我的代码如下所示:

I am stuck. I am playing around with polymer but I do not manage to call the togglePanel function on the drawer panel and my code looks like this:

<!DOCTYPE html> <html> <head> <!-- 1. Load platform.js for polyfill support. --> <script src="bower_components/platform/platform.js"></script> <!-- 2. Use an HTML Import to bring in the element. --> <link rel="import" href="bower_components/core-ajax/core-ajax.html"> <link rel="import" href="bower_components/core-drawer-panel/core-drawer-panel.html"> <link rel="import" href="bower_components/core-toolbar/core-toolbar.html"> <link rel="import" href="bower_components/core-icon-button/core-icon-button.html"> </head> <body> <script> function openDrawer() { alert("fuck"); var drawer = document.getElementById("main-drawer"); drawer.togglePanel(); } </script> <core-drawer-panel id="main-drawer"> <div drawer style="background-color: #FF0000;"> </div> <div main style="background-color: #00FF00;"> <core-toolbar style="background-color: #8888FF;"> <core-icon-button icon="menu" onclick="openDrawer()" on-tap="openDrawer()"></core-icon-button> <div flex>PageTitle</div> </core-toolbar> </div> </core-drawer-panel> </body> </html>

当我单击菜单按钮时,该函数被调用,但没有其他反应,我确保使用警报.

The function gets called when I click the menu button but nothing more happens, i made sure using an alert.

我想这与影子DOM有关,但我不确定.我希望有人知道如何调用它的功能.

I guess it has something to do with the shadow DOM but I am not sure. I hope somebody knows how to call its function.

推荐答案

core-drawer-panel始终保持打开状态.默认情况下,除非您使用的是平板电脑或更小设备,否则它将通常保持打开状态.

core-drawer-panel stays open all the time if the window size is less than responsiveWidth. By default it will generally stay open unless you are on a tablet device or smaller.

如果您将responsiveWidth设置得很高,则可以更改行为,使其仅在需要时打开.

If you set responsiveWidth really high, you can alter the behavior so it only opens on demand.

<core-drawer-panel id="main-drawer" responsiveWidth="900em">

jsbin/zorufa/2/edit

更多推荐

聚合物导航抽屉面板上的调用功能

本文发布于:2023-08-02 17:09:43,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1279600.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:聚合物   抽屉   板上   功能

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!