欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

vue實(shí)現(xiàn)實(shí)時(shí)搜索顯示功能

 更新時(shí)間:2022年04月18日 11:24:55   作者:Amnesia?  
這篇文章主要為大家詳細(xì)介紹了vue實(shí)現(xiàn)實(shí)時(shí)搜索顯示功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了vue實(shí)現(xiàn)實(shí)時(shí)搜索顯示的具體代碼,供大家參考,具體內(nèi)容如下

<template>
//綁定搜索的關(guān)鍵字
<input type="text" class="form-control" placeholder="搜索" v-model="filterInput"/>

?<table ?class="table table-striped">
? ? ? <thead>
? ? ? ? <tr>
? ? ? ? ? <th>姓名</th>
? ? ? ? ? <th>電話</th>
? ? ? ? ? <th>郵箱</th>
? ? ? ? ? <th></th>
? ? ? ? </tr>
? ? ? </thead>
? ? ? <tbody>
? ? ? ? <!-- 遍歷搜索的東西,觸發(fā)filterBy方法遍歷的時(shí)候和搜索框內(nèi)容進(jìn)行匹配 例如name-->
? ? ? ? <!-- 如果不搜索,遍歷的就是所有數(shù)據(jù) -->
? ? ? ? <tr v-for="(item,index) in filterBy(customer,filterInput)" :key="index">
? ? ? ? ? <td>{{item.name}}</td>
? ? ? ? ? <td>{{item.phone}}</td>
? ? ? ? ? <td>{{item.email}}</td>
? ? ? ? ? <!-- 通過對應(yīng)的id查看詳情 ?拼接id-->
? ? ? ? ? <!-- 在details中通過攜帶id發(fā)送后臺請求數(shù)據(jù):to是因?yàn)閠o現(xiàn)在的值是變量要綁定,如果是單純的字符串就不需要綁定-->
? ? ? ? ? <td>
? ? ? ? ? ? <!-- <router-link class="btn btn-default" :to="'/customer/'+item[index]._id" style="backgroundcolor:blue ">查看詳情</router-link> -->
? ? ? ? ? ? <!-- <router-link class="btn btn-default" :to="'/customer/'+item._id" style="backgroundcolor:blue " >查看詳情</router-link> -->
? ? ? ? ? ? <div class="btn btn-default" style="backgroundcolor:blue" @click="handleclick(item)">查看詳情</div>
? ? ? ? ? </td>
? ? ? ? </tr>
? ? ? </tbody>
? ? </table>
? ??
</template>

<script>
export default {
? name: "customers",
? data() {
? ? return {
? ? ? customer: [],
? ? ? filterInput:"",
? ? ? childrenmag:''
? ? };
? },
? ? methods: {
? ? // 異步請求數(shù)據(jù)
? ? async fetchCustomers() {
? ? ? const res = await this.$http.get("/users");
? ? ? this.customer = res.data;
? ? },
? ? filterBy(customers, inputvalue) {
? ? ? // filter方法遍歷整個數(shù)組
? ? ? return customers.filter(customer => {
? ? ? ? // 注意match不能遍里數(shù)字,true,false
? ? ? ? return customer.name.match(inputvalue);
? ? ? });
? ? }
? ? }
</script>

filterBy方法查找對應(yīng)關(guān)鍵字的那條數(shù)據(jù)。

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • element-ui中el-cascader動態(tài)加載和默認(rèn)值詳解

    element-ui中el-cascader動態(tài)加載和默認(rèn)值詳解

    vue+elementUI項(xiàng)目中el-cascader級聯(lián)選擇器使用頻率非常高,下面這篇文章主要給大家介紹了關(guān)于element-ui中el-cascader動態(tài)加載和默認(rèn)值的相關(guān)資料,文中通過實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2023-05-05
  • vue3.0父子傳參,子修改父數(shù)據(jù)的實(shí)現(xiàn)

    vue3.0父子傳參,子修改父數(shù)據(jù)的實(shí)現(xiàn)

    這篇文章主要介紹了vue3.0父子傳參,子修改父數(shù)據(jù)的實(shí)現(xiàn)方式,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-04-04
  • vue2.0中g(shù)oods選購欄滾動算法的實(shí)現(xiàn)代碼

    vue2.0中g(shù)oods選購欄滾動算法的實(shí)現(xiàn)代碼

    這篇文章主要介紹了vue2.0中g(shù)oods選購欄滾動算法的實(shí)現(xiàn)代碼,需要的朋友可以參考下
    2017-05-05
  • Vue過濾器使用方法詳解

    Vue過濾器使用方法詳解

    過濾器的功能是對要顯示的數(shù)據(jù)進(jìn)行格式化后再顯示,其并沒有改變原本的數(shù)據(jù),只是產(chǎn)生新的對應(yīng)的數(shù)據(jù),下面這篇文章主要給大家介紹了關(guān)于Vue中過濾器定義以及使用方法的相關(guān)資料,需要的朋友可以參考下
    2022-12-12
  • Vue中使用Lodash的實(shí)現(xiàn)示例

    Vue中使用Lodash的實(shí)現(xiàn)示例

    本文主要介紹了Vue中使用Lodash的實(shí)現(xiàn)示例,文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-03-03
  • 教你如何開發(fā)Vite3插件構(gòu)建Electron開發(fā)環(huán)境

    教你如何開發(fā)Vite3插件構(gòu)建Electron開發(fā)環(huán)境

    這篇文章主要介紹了如何開發(fā)Vite3插件構(gòu)建Electron開發(fā)環(huán)境,文中給大家提到了如何讓 Vite 加載 Electron 的內(nèi)置模塊和 Node.js 的內(nèi)置模塊,需要的朋友可以參考下
    2022-11-11
  • vue 實(shí)現(xiàn)無規(guī)則截圖

    vue 實(shí)現(xiàn)無規(guī)則截圖

    這篇文章主要介紹了vue 實(shí)現(xiàn)無規(guī)則截圖的方法,幫助大家更好的理解和學(xué)習(xí)使用vue框架,感興趣的朋友可以了解下
    2021-04-04
  • vue使用Split封裝通用拖拽滑動分隔面板組件

    vue使用Split封裝通用拖拽滑動分隔面板組件

    這篇文章主要介紹了vue使用Split封裝通用拖拽滑動分隔面板組件,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2021-03-03
  • vue2.0的contextmenu右鍵彈出菜單的實(shí)例代碼

    vue2.0的contextmenu右鍵彈出菜單的實(shí)例代碼

    本篇文章主要介紹了vue2.0的contextmenu右鍵彈出菜單的實(shí)例代碼,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-07-07
  • Vite配置路徑別名的簡單實(shí)現(xiàn)方法

    Vite配置路徑別名的簡單實(shí)現(xiàn)方法

    Vite項(xiàng)目中我們可以手動將src路徑設(shè)置**@**路徑別名,可以省下很多引入路徑的冗余路徑,下面這篇文章主要給大家介紹了關(guān)于Vite配置路徑別名的簡單實(shí)現(xiàn)方法,需要的朋友可以參考下
    2023-04-04

最新評論