el-select组件添加横向滚动条
1.给el-select设置宽度,使用@focus方法 更新下拉框
<template>
<el-select v-model="listQuery.warehouseSpaceCode"
@focus="setMinWidth"
style="width:100%"
@change="selectWarehouseSpace(listQuery.warehouseSpaceCode)"
placeholder="请选择所属库区 " clearable
>
<el-option
v-for="item in spaceData"
:key="item.code"
:label="item.warehouseName + ':' + item.name"
:value="item.code"
:style="{'width': Width + 'px'}"
/>
</el-select>
<template>
methods: {
// 获取el-select 的宽度 赋值给el-option
setMinWidth (val) {
this.Width = val.srcElement.clientWidth
},
}
<style>
.el-select-dropdown__item{
overflow: visible;
}
</style>