小編給大家分享一下如何實(shí)現(xiàn)vue搜索和vue模糊搜索,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!
1、使用vue來(lái)實(shí)現(xiàn)一般搜索
<form action="" @submit="submitQuery" class="all_two"> <el-input v-model="input" placeholder="請(qǐng)輸入內(nèi)容" ref="search" ></el-input> </form> <div class="all_three"> <div v-for="item in this.$store.state.chufang.alldata"> <div v-for="item1 in queryDate(item.cabinet)" > <input type="checkbox" name="checkbox" value="checkbox" :checked="item1.checks==0? true:false"> <span>{{item1.name}}</span> </div> </div> </div
submitQuery:function(){ this.query = this.$refs.search.value.trim(); },
queryDate:function(list){ if (this.query === '') { return list } return list.filter((item)=>{ if(item.name.indexOf(this.query) != -1){ return item; } }) },
2、vue模糊搜索,原理都是一樣的
<el-form :inline="true" :model="formInline" class="demo-form-inline mt15"> <el-form-item> <el-input v-model="formInline.name" ref="search" placeholder="姓名"></el-input> </el-form-item> <el-form-item> <el-input v-model="formInline.phone" ref="search2" placeholder="手機(jī)號(hào)"></el-input> </el-form-item> <el-form-item> <el-button type="primary" @click="onSubmit">篩選</el-button> </el-form-item> </el-form>
onSubmit() { this.query = this.$refs.search.value.trim(); this.query1 = this.$refs.search2.value.trim(); }, queryDate:function(list){ if (this.query === '' && this.query1 === '') { return list } else if (this.query !== '' && this.query1 === '') { return list.filter(item => { if (item.name.indexOf(this.query) !== -1) { return item } }) } else if (this.query === '' && this.query1 !== '') { return list.filter(item => { if (item.mobile.indexOf(this.query1) !== -1) { return item } }) } else if (this.query !== '' && this.query1 !== '') { return list.filter(item => { if (item.name.indexOf(this.query) !== -1 && item.mobile.indexOf(this.query1) !== -1) { return item } }) } },
以上是“如何實(shí)現(xiàn)vue搜索和vue模糊搜索”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)成都網(wǎng)站設(shè)計(jì)公司行業(yè)資訊頻道!
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。
網(wǎng)頁(yè)標(biāo)題:如何實(shí)現(xiàn)vue搜索和vue模糊搜索-創(chuàng)新互聯(lián)
文章路徑:http://chinadenli.net/article10/dhjsdo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供搜索引擎優(yōu)化、網(wǎng)站排名、做網(wǎng)站、品牌網(wǎng)站建設(shè)、定制開(kāi)發(fā)、用戶體驗(yàn)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容