<template>
<div id="app">
<input oninput="search" type="text" v-model="input" />
<ul>
<li
class="search-item border-bottom"
v-for="item of search"
:key="item.name"
>{
{
item.name}}</li>
</ul>
<!-- <router-view></router-view> -->
</div>
</template>
<script>
export default {
name: "app",
data() {
return {
items: [
{
name: "路飞" },
{
name: "索隆" },
{
name: "娜美" },
{
name: "山治" }
],
input: "",
itemsTwo:[]
};
},
mounted: {
search() {
this.itemsTwo=this.items
if (!this.input) {
this.items=this.itemsTwo
return
}
let arr=this.items.filter(v => {
return v.name.includes(this.input);
});
this.items=arr
}
}
};
</script>
filter模糊查询
Acho que você gosta
Origin blog.csdn.net/YuT_ian/article/details/113372831
Recomendado
Clasificación