HLJ 发布于
2019-03-13 09:47:19

vue实现关键字模糊搜索

vue实现关键字模糊搜索

<input type="text" v-model="filterText2">
<template v-for="(item,index) in viewDictionArr">
  <li>{{item}}</li>
</template>
data(){
  return {
    filterText2:"",
    typeList:[],
  }
},
computed: {
	viewDictionArr(){
		let arr = [];
		for(var i = 0; i < this.typeList.length; i++) {
			if(this.filterText2 != '' && this.typeList[i].value.indexOf(this.filterText2) != -1){
				arr.push(this.typeList[i]);
			}else if(this.filterText2 == ''){
				arr.push(this.typeList[i]);
			}
		}
		return arr;
	}
},


当前文章内容为原创转载请注明出处:http://www.good1230.com/detail/2019-03-13/355.html
最后生成于 2024-05-23 22:50:26
此内容有帮助 ?
0