<el-autocomplete class="inline-input" v-model="state1" :fetch-suggestions="querySearch" placeholder="请输入内容" @select="handleSelect" ></el-autocomplete> <ul> <li v-for="(item,index) in searchList">{{item.value}}</li> </ul>
state1: '', searchList: [],
querySearch(queryString, cb) { var restaurants = this.restaurants; var results = queryString ? restaurants.filter(this.createFilter(queryString)) : restaurants; // 调用 callback 返回建议列表的数据 cb(results); if(!queryString){ this.searchList = this.loadAll(); } }, createFilter(queryString) { return (restaurant) => { return (restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0); }; }, handleSelect(item) { this.searchList=[] this.searchList.push(item) console.log('this.searchList',this.searchList); }, loadAll() { return [ { value: "06三财(2018)1412号" }, { value: "01琼财行(2017)1100号" }, { value: "04三财(2016)500号" }, { value: "05财行(2016)71号" }, ] },
mounted() { this.restaurants = this.loadAll(); }