Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.2k views
in Technique[技术] by (71.8m points)

el-select多选以tag展示时,超过显示长度以...省略号显示

tag标签过长时,会出现“溢出”的情况,想要当超过后自动截取并以省略号显示
目前
image.png
想要实现的结果
image.png
目前的写法没有实现
代码

<el-select
                        v-show="overviewVO.adType !== 'COMPANY'"
                        :multiple="overviewVO.adType === 'GROUP' ? true : false"
                        collapse-tags
                        v-model="ancountVO.advertisersId"
                        placeholder="请选择广告组"
                        size="small"
                        @change="selectAdvertisers"
                        clearable
                    >
                    <el-option
                        v-for="item in codeList.advertisersList"
                        :key="item.advertisersId"
                        :label="item.advertisersName"
                        :value="item.advertisersId"
                    />
                    </el-select>

css:

// select的tags过长显示...
.el-select__tags-text {
  display: inline-block;
  max-width: 140px;
  @media (max-width: 1400px) {
    max-width: 42px;
  }
  overflow: hidden;
  text-overflow:ellipsis;
  white-space: nowrap;
}
.el-select .el-tag__close.el-icon-close {
  top: -7px;
  right: -4px;
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

可以看下这个,如果不行应该需要配合/deep/使用:

.el-cascader__tags .el-tag:nth-child(1){
  max-width: 100px;
  overflow:hidden;
}

image.png


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...