Paper elements Light html中纸张下拉菜单的Eventlistener

Paper elements Light html中纸张下拉菜单的Eventlistener,paper-elements,lit-html,Paper Elements,Lit Html,我在一个lit html项目中,使用谷歌的一些材料设计元素。文件xxx 我正在努力从纸张下拉菜单中触发事件。我已按如下方式实施: 在render()中 我不完全确定iron select是否是要听的正确事件,但似乎是这样: 应用程序可以监听iron select和iron deselect事件 选择和取消选择选项时作出反应的步骤 资料来源: 当所选项目发生变化时,使用iron select收听是否正确?我做错了什么?这太尴尬了,忘了影根 这很有效 firstUpdated(){ const c

我在一个lit html项目中,使用谷歌的一些材料设计元素。文件xxx

我正在努力从
纸张下拉菜单中触发事件。我已按如下方式实施:

在render()中

我不完全确定
iron select
是否是要听的正确事件,但似乎是这样:

应用程序可以监听
iron select
iron deselect
事件 选择和取消选择选项时作出反应的步骤 资料来源:


当所选项目发生变化时,使用
iron select
收听是否正确?我做错了什么?

这太尴尬了,忘了影根

这很有效

firstUpdated(){
 const changePositionDropdown = this.shadowRoot.querySelector('#changePositionDropdown');

    changePositionDropdown.addEventListener('iron-select', (e)=>{
        console.log("Hello there");
    });
}
也可以使用
@事件


1.

此外,我最近尝试了使用lit元素的纸张下拉菜单。最后,我在paper listbox元素上使用@selected changed=“${(e)=>{this.changedHandler(e)}}>”,并在处理程序中使用e.detail.value。另见本帖:
const changePositionDropdown = document.getElementById("changePositionDropdown");
    changePositionDropdown.addEventListener('iron-select', (e)=>{
        console.log("Hello there");
    });
firstUpdated(){
 const changePositionDropdown = this.shadowRoot.querySelector('#changePositionDropdown');

    changePositionDropdown.addEventListener('iron-select', (e)=>{
        console.log("Hello there");
    });
}
<paper-dropdown-menu 
    label="Endre rekkefølge"
    id="changePositionDropdown"
    @iron-select="${(e)=>{console.log("surprise")}}"> <!-- using the @ to handle the vent-->
    <paper-listbox 
        slot="dropdown-content" 
        class="dropdown-content" 
        selected="${this.positionForVideoInPlaylist-1}">
        <paper-item>1</paper-item>
    </paper-listbox>
</paper-dropdown-menu>