gpt4 book ai didi

javascript - polymer :纸张操作对话框打开时纸张菜单按钮不会关闭

转载 作者:行者123 更新时间:2023-12-02 14:49:29 24 4
gpt4 key购买 nike

我有一个纸质菜单按钮,在同一页面中有一个纸质操作对话框。像这样:

    function openDialog() {
document.querySelector('#dialog').toggle();
};
<script src="//www.polymer-project.org/components/platform/platform.js"></script>
<link rel="import" href="//www.polymer-project.org/components/polymer/polymer.html">
<link rel="import" href="//www.polymer-project.org/components/paper-dialog/paper-action-dialog.html">
<link rel="import" href="//www.polymer-project.org/components/paper-menu-button/paper-menu-button.html">
<link rel="import" href="//www.polymer-project.org/components/paper-button/paper-button.html">
<link rel="import" href="//www.polymer-project.org/components/paper-icon-button/paper-icon-button.html">
<link rel="import" href="//www.polymer-project.org/components/paper-dropdown/paper-dropdown.html">
<link rel="import" href="//www.polymer-project.org/components/core-menu/core-menu.html">
<link rel="import" href="//www.polymer-project.org/components/paper-item/paper-item.html">

<paper-action-dialog id="dialog" heading="Dialog Title" backdrop>
<p>Some content</p>
<paper-button dismissive>More Info</paper-button>
<paper-button affirmative>Decline</paper-button>
<paper-button affirmative>Accept</paper-button>
</paper-action-dialog>

<button type="button" onclick="openDialog()">Click Me!</button>

<br/> <br/>

<paper-menu-button>
<paper-icon-button icon="menu" noink></paper-icon-button>
<paper-dropdown class="dropdown">
<core-menu class="menu">
<paper-item>Share</paper-item>
<paper-item>Settings</paper-item>
<paper-item>Help</paper-item>
</core-menu>
</paper-dropdown>
</paper-menu-button>

当我单击打开菜单按钮但不关闭它并单击按钮打开操作对话框时,菜单按钮保持打开状态。我尝试用以下方法关闭它:

document.querySelector('core-overlay-layer').opened = false;

并与:

$('core-overlay-layer').removeClass('core-opened');

但是核心覆盖层不会以这种方式正确关闭,如果您尝试再次打开菜单按钮,第一次单击时它将关闭最后一个打开的隐藏菜单按钮。在打开操作对话框之前关闭菜单按钮的正确方法是什么?

最佳答案

我在组件的文档中看到过:paper-menu-button。

overlayListeners: {
'core-overlay-open': 'openAction',
'core-activate': 'activateAction'
},

activateAction: function() {
this.opened = false;
}

所以我会这样做:

    function openDialog() {
document.querySelector('#dialog').toggle();
document.querySelector('paper-menu-button').opened = false;
};

打开时是整个元素的属性。

关于javascript - polymer :纸张操作对话框打开时纸张菜单按钮不会关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27861875/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com