1. 程式人生 > 其它 >Elementui中el-select 選項框前新增自定義icon圖示

Elementui中el-select 選項框前新增自定義icon圖示

技術標籤:elementUIel-select自定義icon

一 效果圖

二 程式碼

百度很久都沒找到類似的說明,自己就嘗試一下用class寫了

<el-select v-model="value" class="year">
   <el-option value="2019" label="2019"></el-option>
</el-select>



.year {
    /deep/.el-input__inner {  //如果你的style 加了scoped 需要加/deep/
      background: url('
[email protected]
/assets/img/boardsurvey/icon/year.png') no-repeat; //引入icon background-size: 16px 14px; //這個是圖片的大小,在這裡不能直接設定width height,設定寬高其實是select的寬高,圖片可能會失真只設置寬度 高度auto也行 background-position: 4px 5px; //在input中定位置 這兩個引數是x y座標 padding: 0 0 0 26px; //需要設定padding 把placeholder向右移 box-sizing: border-box; font-size: 14px; } }

加油加油