vue中el表單的簡單查詢方法
更新時間:2023年10月31日 14:33:46 作者:m0_56666791
本文主要介紹了vue中el表單的簡單查詢方法,主要包括表單頁面根據(jù)groupid 、type 、errortype進行數(shù)據(jù)過濾,感興趣的可以了解一下
預期效果
實現(xiàn)表單頁面根據(jù)groupid 、type 、errortype進行數(shù)據(jù)過濾
實現(xiàn)
第一步,在頁面中添加輸入或者是下拉框,并且用相應的v-model進行綁定
<div style="display: flex;flex-direction: row;"> <el-input style="width: auto;height:32px" placeholder="輸入故障設備組" v-model="groupid"></el-input> <el-form-item> <el-select v-model="type" placeholder="請選擇故障類型"> <el-option v-for="(item, index) in typeOptions" :key="index" :label="item.label" :value="item.value"></el-option> </el-select> </el-form-item> <el-form-item> <el-select v-model="errortype" placeholder="請選擇故障原因"> <el-option v-for="(item, index) in errtypeOptions" :key="index" :label="item.label" :value="item.value"></el-option> </el-select> </el-form-item> </div>
第二步,添加查詢按鈕 按鈕綁定查詢方法
<el-button type="primary" @click="search" style="margin-left: 5px">查詢數(shù)據(jù)</el-button>
第三步
此時已經(jīng)很多報錯了,趕緊定義所需的數(shù)據(jù)和方法!
定義v-model綁定的數(shù)據(jù),存儲查詢的東西
const groupid = ref("") const type = ref("") const errortype = ref("")
定義下拉框內(nèi)容
let typeOptions = ref([ { label: "一般故障", value: "一般故障" }, { label: "緊急故障", value: "緊急故障" }, { label: "特大故障", value: "特大故障" } ]); let errtypeOptions = ref([ { label: "溫度", value: "溫度" }, { label: "電流", value: "電流" }, { label: "電壓", value: "電壓" } ]);
第三步
定義搜索方法
//查詢數(shù)據(jù) const search = () => { if (groupid.value != "") { tableData.value = tableData.value.filter(v => v.groupid == (groupid.value)) console.log(1); } if (type.value != "") { tableData.value = tableData.value.filter(v => v.type.includes(type.value)) console.log(2); } if (errortype.value != "") { tableData.value = tableData.value.filter(v => v.errortype.includes(errortype.value)) console.log(3); } }
這里的if是去除掉如果用戶未輸入內(nèi)容的時候也進行過濾的情況的,通過多次過濾,我們可以任意選擇篩選的情況
到此這篇關于vue中el表單的簡單查詢方法的文章就介紹到這了,更多相關vue el表單內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
您可能感興趣的文章:
- Avue實現(xiàn)動態(tài)查詢與數(shù)據(jù)展示的示例代碼
- vue中輕量級模糊查詢fuse.js使用方法步驟
- 5種vue模糊查詢的方法總結(jié)
- vue+element?ui表格添加多個搜索條件篩選功能(前端查詢)
- vue中wangEditor的使用及回顯數(shù)據(jù)獲取焦點的方法
- Vue前端如何實現(xiàn)與后端進行數(shù)據(jù)交互
- vue.js前后端數(shù)據(jù)交互之提交數(shù)據(jù)操作詳解
- 詳解vue與后端數(shù)據(jù)交互(ajax):vue-resource
- Vue?3?表單與后端數(shù)據(jù)交互之查詢并回顯數(shù)據(jù)步驟流程
相關文章
基于elementUI使用v-model實現(xiàn)經(jīng)緯度輸入的vue組件
這篇文章主要介紹了基于elementUI使用v-model實現(xiàn)經(jīng)緯度輸入的vue組件,本文給大家介紹的非常詳細,具有一定的參考借鑒價值,需要的朋友可以參考下2019-05-05vue實現(xiàn)虛擬滾動渲染成千上萬條數(shù)據(jù)
本文主要介紹了vue實現(xiàn)虛擬滾動渲染成千上萬條數(shù)據(jù),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2023-02-02Vue中使用 Echarts5.0 遇到的一些問題(vue-cli 下開發(fā))
這篇文章主要介紹了Vue中使用 Echarts5.0 遇到的一些問題(vue-cli 下開發(fā)),具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2022-10-10