直接上图上代码,直接复制即可
<template>
<div class="myselect" :class="{'open': openIcon}">
<el-select v-model="value" placeholder="请选择" @visible-change="openTrue">
<el-option
v-for="item in options"
:key="item.value"
:label="item.label"
:value="item.value"
>
</el-option>
</el-select>
<i class="el-icon-caret-bottom open-icon"></i>
</div>
</template>
<script>
export default {
data() {
return {
options: [
{
value: "选项1",
label: "黄金糕",
},
{
value: "选项2",
label: "双皮奶",
},
{
value: "选项3",
label: "蚵仔煎",
},
{
value: "选项4",
label: "龙须面",
},
{
value: "选项5",
label: "北京烤鸭",
},
],
value: "",
openIcon:false,
};
},
methods:{
openTrue(val){
this.openIcon = val
}
}
};
</script>
<style lang="scss">
.myselect {
width:217px;
transition: all 1s;
position: relative;
.el-input__suffix {
display: none;
}
.open-icon {
position: absolute;
right: 10px;
top: 9px;
font-size: 14px;
}
/* 修改 placeholder 初始化颜色*/
.el-input__inner::placeholder {
color: #1f2329;
}
/* 谷歌 */
.el-input__inner::-webkit-input-placeholder:hover {
color: #1f2329;
}
/* 火狐 */
.el-input__inner:-moz-placeholder {
color: #1f2329;
}
/*ie*/
.el-input__inner:-ms-input-placeholder {
color: #1f2329;
}
/* 修改 placeholder 鼠标滑上颜色*/
&:hover{
.el-input__inner::placeholder {
color: #3370ff;
}
/* 谷歌 */
.el-input__inner::-webkit-input-placeholder:hover {
color: #3370ff;
}
/* 火狐 */
.el-input__inner:-moz-placeholder {
color: #3370ff;
}
/*ie*/
.el-input__inner:-ms-input-placeholder {
color: #3370ff;
}
.open-icon{
color: #3370ff;
}
}
.el-input__inner {
border: 1px solid #1f2329;
&:hover{
color: #3370ff;
border-color: #3370ff;
background-color: #e1eaff;
}
}
}
.open{
.open-icon{
transform: rotate(180deg);
}
}
</style>