vue中el表單的簡單查詢方法
預(yù)期效果
實現(xiàn)表單頁面根據(jù)groupid 、type 、errortype進(jìn)行數(shù)據(jù)過濾
實現(xiàn)
第一步,在頁面中添加輸入或者是下拉框,并且用相應(yīng)的v-model進(jìn)行綁定
<div style="display: flex;flex-direction: row;">
<el-input style="width: auto;height:32px" placeholder="輸入故障設(shè)備組" 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)容的時候也進(jìn)行過濾的情況的,通過多次過濾,我們可以任意選擇篩選的情況
到此這篇關(guān)于vue中el表單的簡單查詢方法的文章就介紹到這了,更多相關(guān)vue el表單內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
- Avue實現(xiàn)動態(tài)查詢與數(shù)據(jù)展示的示例代碼
- vue中輕量級模糊查詢fuse.js使用方法步驟
- 5種vue模糊查詢的方法總結(jié)
- vue+element?ui表格添加多個搜索條件篩選功能(前端查詢)
- vue中wangEditor的使用及回顯數(shù)據(jù)獲取焦點(diǎn)的方法
- Vue前端如何實現(xiàn)與后端進(jìn)行數(shù)據(jù)交互
- vue.js前后端數(shù)據(jù)交互之提交數(shù)據(jù)操作詳解
- 詳解vue與后端數(shù)據(jù)交互(ajax):vue-resource
- Vue?3?表單與后端數(shù)據(jù)交互之查詢并回顯數(shù)據(jù)步驟流程
相關(guān)文章
基于elementUI使用v-model實現(xiàn)經(jīng)緯度輸入的vue組件
這篇文章主要介紹了基于elementUI使用v-model實現(xiàn)經(jīng)緯度輸入的vue組件,本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價值,需要的朋友可以參考下2019-05-05
Vue實現(xiàn)導(dǎo)航欄的顯示開關(guān)控制
今天小編就為大家分享一篇Vue實現(xiàn)導(dǎo)航欄的顯示開關(guān)控制,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-11-11
JavaScript獲取echart曲線上任意點(diǎn)位的值詳解
這篇文章主要為大家介紹了JavaScript獲取echart曲線上任意點(diǎn)位的值詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-09-09
vue實現(xiàn)虛擬滾動渲染成千上萬條數(shù)據(jù)
本文主要介紹了vue實現(xiàn)虛擬滾動渲染成千上萬條數(shù)據(jù),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2023-02-02
Vue中使用 Echarts5.0 遇到的一些問題(vue-cli 下開發(fā))
這篇文章主要介紹了Vue中使用 Echarts5.0 遇到的一些問題(vue-cli 下開發(fā)),具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2022-10-10

