问题
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