2017-04-24 58 views
0

我正在使用聚合物2.0預覽。 我<paper-dropdown-menu>這樣的:從兩行紙張下拉菜單中選擇第一項

<paper-dropdown-menu label="Your devices..." style="margin: 0;"> 
    <paper-listbox slot="dropdown-content" selected="1"> 
     <paper-icon-item> 
      <iron-icon icon="hardware:phone-android" slot="item-icon"></iron-icon> 
      <paper-item-body two-line> 
       <div>PLAY LGE LG-H440n</div> 
       <div secondary>Last sync: Jan 9, 2014</div> 
      </paper-item-body> 
     </paper-icon-item> 
     <paper-icon-item value="PLAY ASUS Nexus7 2012 WIFI"> 
      <iron-icon icon="hardware:tablet-android" slot="item-icon"></iron-icon> 
      <paper-item-body two-line> 
       <div>PLAY ASUS Nexus7 2012 WIFI</div> 
       <div secondary>last sync: Jan 9, 2014</div> 
      </paper-item-body> 
     </paper-icon-item> 
    </paper-listbox> 
</paper-dropdown-menu> 

當我選擇例如第一個項目,我所得到的是

PLAY LG電子LG-H440nLast同步:2014年1月9日

什麼我想要的是

PLAY LGE LG-H440n

我只需要顯示第一行。我試圖將value設置爲<paper-icon-item>,但它不起作用。我怎樣才能做到這一點,而不創建我自己的組件?它甚至有可能嗎?

回答

1

好的,我明白了。按照docummentation在paper-dropdown-menu.html文件:

<paper-input 
    type="text" 
    invalid="[[invalid]]" 
    readonly 
    disabled="[[disabled]]" 
    value="[[selectedItemLabel]]" 
    placeholder="[[placeholder]]" 
    error-message="[[errorMessage]]" 
    always-float-label="[[alwaysFloatLabel]]" 
    no-label-float="[[noLabelFloat]]" 
    label="[[label]]"> 

... 

/** 
* The derived "label" of the currently selected item. This value 
* is the `label` property on the selected item if set, or else the 
* trimmed text content of the selected item. 
*/ 
selectedItemLabel: { 
    type: String, 
    notify: true, 
    readOnly: true 
} 

我需要設置label<paper-icon-item>元素。

相關問題