当动态添加纸张下拉菜单项时,其标签不会更新, 但其选定的值正在变化,但未在标签
中显示它在PLUNKER中说明:https://plnkr.co/edit/jy7WxttkB1mN7z0uHuVJ?p=preview
<paper-dropdown-menu label="Patient">
<paper-menu class="dropdown-content" selected="{{selectedPatient}}" attr-for-selected="value">
<template is="dom-repeat" id="patientMenu" items="[[patientsList]]">
<paper-item class="patient-names" value="[[item.id]]">[[item.id]][[item.name]]</paper-item>
</template>
</paper-menu>
<paper-button on-tap="_fun" raised>change Array list</paper-button>
<div style="color:blue;">selected patient id--->[[selectedPatient]]</div>
Polymer({
is: 'my-test',
properties: {
patientsList:{
type:Array
}
},
ready:function() {
this.patientsList =[
{id:0,name:"aaa"},
{id:1,name:"bbb"},
{id:2,name:"ccc"},
{id:3,name:"ddd"},
{id:4,name:"eee"}
];
this.selectedPatient = 0;
},
_fun:function(){
this.selectedPatient = null;
this.patientsList = [
{id:100,name:"xxx"},
{id:101,name:"yyy"},
{id:102,name:"qqq"},
{id:103,name:"mmm"},
{id:4,name:"eee"}
];
this.selectedPatient = 100;
}
答案 0 :(得分:2)
我尝试你的plunker,特别是“它第二次工作”部分,让我们认为问题可能是dom-repeat
没时间更新项目
this.selectedPatient = 100;
已执行。
我尝试将其更改为
this.async(function(){
this.set('selectedPatient',100)
}.bind(this));
确保selectedPatient
仅在dom-repeat
更新后设置,并且似乎可以解决问题。