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 LGE LG-H440n上次同步:2014 年 1 月 9 日

我想要的是

玩 LGE LG-H440n

我只需要显示第一行。我试图设置value<paper-icon-item>但它不起作用。在不创建自己的组件的情况下如何做到这一点?甚至可能吗?

4

1 回答 1

2

好的,我明白了。根据文件中的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>元素。

于 2017-04-24T11:18:20.087 回答