elementUI組件el-dropdown(踩坑)
選擇即改變:click選擇哪個,就顯示當(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)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Vue.js綁定HTML class數(shù)組語法錯誤的原因分析
Vue.js綁定HTML class數(shù)組語法錯誤有哪些原因?qū)е碌哪?,該如何解決呢?下面小編給大家分享Vue.js綁定HTML class數(shù)組語法錯誤的原因分析,感興趣的朋友一起看看吧2016-10-10
Vue實(shí)現(xiàn)省市區(qū)三級聯(lián)動el-select組件的示例代碼
這篇文章主要為大家詳細(xì)介紹了Vue實(shí)現(xiàn)省市區(qū)三級聯(lián)動el-select組件的方法,文中的示例代碼講解詳細(xì),具有一定的借鑒價(jià)值,需要的的可以參考一下2023-02-02
使用vue開發(fā)移動端管理后臺的注意事項(xiàng)
這篇文章主要介紹了使用vue開發(fā)移動端管理后臺的注意事項(xiàng),小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2019-03-03
vue.js實(shí)現(xiàn)數(shù)據(jù)動態(tài)響應(yīng) Vue.set的簡單應(yīng)用
這篇文章主要介紹了vue.js實(shí)現(xiàn)數(shù)據(jù)動態(tài)響應(yīng),Vue.set的簡單應(yīng)用,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-06-06
vue3中使用ant-design-vue的layout組件實(shí)現(xiàn)動態(tài)導(dǎo)航欄和面包屑功能
這篇文章主要介紹了vue3中使用ant-design-vue的layout組件實(shí)現(xiàn)動態(tài)導(dǎo)航欄和面包屑功能,基于一個新建的Vue3項(xiàng)目上實(shí)現(xiàn),本文結(jié)合示例代碼給大家介紹的非常詳細(xì),需要的朋友可以參考下2023-01-01

