Polymer 1.0.5: Select not working on paper-dropdown-menu

↘锁芯ラ 提交于 2019-12-10 12:15:38

问题


I can't seem to set a default selected option, if needed. Read the docs but no other properties, except for label works.

  <paper-dropdown-menu label="I Love:">
    <paper-menu class="dropdown-content" selectedItem="Heroes Reborn">
      <paper-item>Teen Wolf</paper-item>
      <paper-item>Heroes Reborn</paper-item>
      <paper-item>Once Upon a Time</paper-item>
    </paper-menu>
  </paper-dropdown-menu>

No matter if I set a value on paper-item value="x" then <paper-menu selected="x"> nothing works. Do I need to run some other script?


回答1:


Setting selected to an integer should work. If you want to select the second item set <paper-menu selected="1">.

If you want to use value instead of an integer index, set attr-for-selected="value"

    <paper-menu attr-for-selected="value" selected="heroes" class="dropdown-content">
        <paper-item value="teen">Teen Wolf</paper-item>
        <paper-item value="heroes">Heroes Reborn</paper-item>
        <paper-item value="once">Once Upon a Time</paper-item>
    </paper-menu>


来源:https://stackoverflow.com/questions/31982671/polymer-1-0-5-select-not-working-on-paper-dropdown-menu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!