Javascript 如何按值选择下拉菜单dom repeat Dropdown
在Polymer中刷新页面后,我尝试在下拉设置中重新加载。下拉列表从AJAX调用动态加载,一旦下拉列表设置为set,它就会保存在localStorage中Javascript 如何按值选择下拉菜单dom repeat Dropdown,javascript,drop-down-menu,polymer,polymer-2.x,dom-repeat,Javascript,Drop Down Menu,Polymer,Polymer 2.x,Dom Repeat,在Polymer中刷新页面后,我尝试在下拉设置中重新加载。下拉列表从AJAX调用动态加载,一旦下拉列表设置为set,它就会保存在localStorage中 <select id="customer" on-change="selectCustomer"> <option value="" selected disabled>Select Customer</option> <template is="dom-repeat" items
<select id="customer" on-change="selectCustomer">
<option value="" selected disabled>Select Customer</option>
<template is="dom-repeat" items="[[customers]]" as="customer" index-as="index">
<option value="[[customer]]">[[customer]]</option>
</template>
</select>
我试过了
setDropdown() {
// index generated in text matching for loop
this.$.customer.selectedIndex = index;
)
及
我认为更好的方法是将下拉列表值绑定到属性
customer
,然后观察customer
的值并将其保存到本地存储。。。在连接的回调上同步它
setDropdown() {
// index generated in text matching for loop
this.$.customer.selectedIndex = index;
)
setDropdown() {
// customerName generated in text matching for loop
this.$.customer.value = customerName;
)