el-select選擇器組件下拉框增加自定義按鈕的實現
更新時間:2024年07月05日 11:58:13 作者:程序猿想成程序獅
本文主要介紹了el-select選擇器組件下拉框增加自定義按鈕的實現,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
先看效果
原理:在el-select下添加禁用的el-option,將其value綁定為undefined,然后覆蓋el-option禁用狀態(tài)下的默認樣式即可
示例代碼如下:
<template> <div class="extra-button-select" style="padding: 20px"> <el-select v-model="selected"> <el-option v-for="option in options" :key="option.id" :label="option.label" :value="option.id" ></el-option> <el-option disabled style="cursor: pointer"> <el-button type="text" @click="onClickBtn1"><i class="el-icon-menu"></i> 按鈕1</el-button> </el-option> <el-option :value="undefined" disabled style="cursor: pointer"> <el-button type="text" @click="onClickBtn2"><i class="el-icon-menu"></i> 按鈕2</el-button> </el-option> </el-select> </div> </template> <script> export default { name: 'extra-button-select', data() { return { selected: 1, options: [ { id: 1, label: 'Option 1', }, { id: 2, label: 'Option 2', } ] } }, methods: { onClickBtn1() { this.$message.info('點擊了按鈕1') }, onClickBtn2() { this.$message.info('點擊了按鈕2') } } } </script> <style scoped lang="scss"> </style>
到此這篇關于el-select選擇器組件下拉框增加自定義按鈕的實現的文章就介紹到這了,更多相關el-select選擇器下拉框自定義按鈕內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
相關文章
Vue中router.beforeEach與beforeRouteEnter的區(qū)別及說明
這篇文章主要介紹了Vue中router.beforeEach與beforeRouteEnter的區(qū)別及說明,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2022-10-10vue使用百度地圖報錯BMap?is?not?defined問題及解決
這篇文章主要介紹了vue使用百度地圖報錯BMap?is?not?defined問題及解決,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2022-10-10