1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| data: () => ( { options: [{ value: '选项1', label: '黄金糕' }, { value: '选项2', label: '双皮奶' }, { value: '选项3', label: '蚵仔煎' }, { value: '选项4', label: '龙须面' }, { value: '选项5', label: '北京烤鸭' }], showList:[], value:'' } ), methods:{ filterList(query) { if(!query){ this.showList = this.options.slice(0,100) }else{ let result = [] this.options.forEach(val=>{ if(val.label.includes(query)) result.push(val) }) this.showList = result.slice(0,100) } }, }, created(){ this.showList = this.options.slice(0,100) }
|