项目中使用级联选择器(el-cascader)的时候会遇到个项的文字过多导致区域过长,因此需要设置最大的宽度,然后给组件提供的–自定义节点内容-来设置实现鼠标悬停显示;
最终效果如下:
代码如下
.el-cascader-menu{
max-width:250px;
}
<template slot-scope="{ node, data }">
<el-tooltip :disabled="data.title.length < 11" class="item" effect="dark" :content="data.title" placement="top-start">
<span>{{ data.unitName }}</span>
</el-tooltip>
</template>