elementUI組件el-dropdown(踩坑)
選擇即改變:click選擇哪個(gè),就顯示當(dāng)前的值,頁面UI顯示并伴隨css樣式的變化。
重點(diǎn):v-if 和 v-else-if 的搭配使用,缺一不可。
效果圖:

正確的代碼如下:
重要提示:
我之前使用的全部是v-if判斷,沒有搭配v-else-if,所以就出現(xiàn)了bug:即只能點(diǎn)擊一次,(然后就失效了)就不能繼續(xù)點(diǎn)擊了。
但是我想要的功能:是能改變之前的選擇狀態(tài)。
所以,才有了下面的代碼優(yōu)化(邏輯上的優(yōu)化)。
<div class="it-after" v-if=" resume.phone != ''">
<p class="it-telphone clamp1">{{resume.phone}}</p>
<div class="btn3"><el-button type="primary" icon="el-icon-warning" plain @click="open3">舉報(bào)該簡歷</el-button></div>
<div class="btn3" style="margin-top:5px;">
<el-dropdown @command="resumeStateFun">
<el-button type="primary" v-if="resume.status==0">
<span :id="'span_'+resume.resumeCode">未標(biāo)記</span><i class="el-icon-arrow-down el-icon--right"></i>
</el-button>
<el-button type="primary" v-else-if="resume.status==1">
<span :id="'span_'+resume.resumeCode">已面試</span><i class="el-icon-arrow-down el-icon--right"></i>
</el-button>
<el-button type="primary" v-else-if="resume.status==2">
<span :id="'span_'+resume.resumeCode">待面試</span><i class="el-icon-arrow-down el-icon--right"></i>
</el-button>
<el-button type="primary" v-else-if="resume.status==3">
<span :id="'span_'+resume.resumeCode">不合適</span><i class="el-icon-arrow-down el-icon--right"></i>
</el-button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item :command="resume.resumeCode+'_0'">未標(biāo)記</el-dropdown-item>
<el-dropdown-item :command="resume.resumeCode+'_1'">已面試</el-dropdown-item>
<el-dropdown-item :command="resume.resumeCode+'_2'">待面試</el-dropdown-item>
<el-dropdown-item :command="resume.resumeCode+'_3'">不合適</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</div>
</div>
總結(jié):
需要 v-if 和 v-else-if 搭配使用,(完整的判斷邏輯)操作起來,才能讓顯示效果正常
到此這篇關(guān)于elementUI組件el-dropdown(踩坑)的文章就介紹到這了,更多相關(guān)element el-dropdown內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
- Vue+EleMentUI實(shí)現(xiàn)el-table-colum表格select下拉框可編輯功能實(shí)例
- ElementUI中el-dropdown-item點(diǎn)擊事件無效問題
- vue中使用el-dropdown方式
- elementUI中el-dropdown的command實(shí)現(xiàn)傳遞多個(gè)參數(shù)
- ElementUI中的el-dropdown傳入多參數(shù)的實(shí)現(xiàn)方法
- vue+element搭建后臺(tái)小總結(jié) el-dropdown下拉功能
- el-table表頭使用el-dropdown出現(xiàn)兩個(gè)下拉框的問題及解決方法
相關(guān)文章
Vue路由組件的緩存keep-alive和include屬性的具體使用
:瀏覽器頁面在進(jìn)行切換時(shí),原有的路由組件會(huì)被銷毀,通過緩存可以保存被切換的路由組件,本文主要介紹了Vue路由組件的緩存keep-alive和include屬性的具體使用,感興趣的可以了解一下2023-11-11
Vue中@click.stop和@click.prevent實(shí)例詳解
當(dāng)我們使用Vue.js開發(fā)前端應(yīng)用時(shí),經(jīng)常會(huì)在模版中使用@click指令來響應(yīng)用戶的點(diǎn)擊事件,這篇文章主要給大家介紹了關(guān)于Vue中@click.stop和@click.prevent的相關(guān)資料,需要的朋友可以參考下2024-04-04
Vue學(xué)習(xí)筆記進(jìn)階篇之過渡狀態(tài)詳解
本篇文章主要介紹了Vue學(xué)習(xí)筆記進(jìn)階篇之過渡狀態(tài)詳解,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-07-07
vue項(xiàng)目開發(fā)環(huán)境工具node搭建過程
最近在開始接觸做vue框架的前端項(xiàng)目,以前用的前端比如html,js,css等都是比較原生的,寫好后直接瀏覽器打開就行,今天就先記錄一下vue的開發(fā)運(yùn)行搭建過程,感興趣的朋友一起看看吧2023-09-09
vue如何使用element-ui 實(shí)現(xiàn)自定義分頁
這篇文章主要介紹了vue如何使用element-ui 實(shí)現(xiàn)自定義分頁,可以通過插槽實(shí)現(xiàn)自定義的分頁,本文通過實(shí)例圖文相結(jié)合給大家介紹的非常詳細(xì),感興趣的朋友一起看看吧2024-07-07

