vue中el表單的簡(jiǎn)單查詢方法
預(yù)期效果
實(shí)現(xiàn)表單頁面根據(jù)groupid 、type 、errortype進(jìn)行數(shù)據(jù)過濾
實(shí)現(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="請(qǐng)選擇故障類型">
<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="請(qǐng)選擇故障原因">
<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>
第三步
此時(shí)已經(jīng)很多報(bào)錯(cuò)了,趕緊定義所需的數(shù)據(jù)和方法!
定義v-model綁定的數(shù)據(jù),存儲(chǔ)查詢的東西
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)容的時(shí)候也進(jìn)行過濾的情況的,通過多次過濾,我們可以任意選擇篩選的情況
到此這篇關(guān)于vue中el表單的簡(jiǎn)單查詢方法的文章就介紹到這了,更多相關(guān)vue el表單內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
- Avue實(shí)現(xiàn)動(dòng)態(tài)查詢與數(shù)據(jù)展示的示例代碼
- vue中輕量級(jí)模糊查詢fuse.js使用方法步驟
- 5種vue模糊查詢的方法總結(jié)
- vue+element?ui表格添加多個(gè)搜索條件篩選功能(前端查詢)
- vue中wangEditor的使用及回顯數(shù)據(jù)獲取焦點(diǎn)的方法
- Vue前端如何實(shí)現(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)文章
進(jìn)入Hooks時(shí)代寫出高質(zhì)量react及vue組件詳解
這篇文章主要介紹了Hooks時(shí)代中如何寫出高質(zhì)量的react和vue組件的示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-07-07
Vue數(shù)據(jù)驅(qū)動(dòng)模擬實(shí)現(xiàn)5
這篇文章主要介紹了Vue數(shù)據(jù)驅(qū)動(dòng)模擬實(shí)現(xiàn)的相關(guān)資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-01-01
Vue監(jiān)聽localstorage變化的方法詳解
在日常開發(fā)中,我們經(jīng)常使用localStorage來存儲(chǔ)一些變量,這些變量會(huì)存儲(chǔ)在瀏覽中,對(duì)于localStorage來說,即使關(guān)閉瀏覽器,這些變量依然存儲(chǔ)著,方便我們開發(fā)的時(shí)候在別的地方使用,本文就給大家介紹Vue如何監(jiān)聽localstorage的變化,需要的朋友可以參考下2023-10-10

