对象用for of 数组用for in
for in 如果想要循环对象的话要用 object.keys
<div
class="aa"
v-for="(item, key) of cities"
:key="key"
:ref="key"
v-show="show == false"
>
<div class="dd">
<span class="z">{{ key }}</span>
</div>
</div>
搜索
inout() {
if (this.value == "") {
this.show = false;
} else {
this.show = true;
}
var arr = [];
for (var i in this.cities) {
this.cities[i].forEach(item => {
if (
item.name.indexOf(this.value) > -1 ||
item.spell.indexOf(this.value) > -1
) {
console.log(item);
arr.push(item);
}
});
}
this.list1 = arr;
console.log(this.list1);
},