美文网首页
解决el-tree文本内容过多显示不完全问题

解决el-tree文本内容过多显示不完全问题

作者: 为什么划船不靠桨 | 来源:发表于2023-04-27 17:27 被阅读0次

    解决后的最终展示效果是el-tree溢出部分以省略号显示,鼠标悬停在文本上会显示出文本全部内容。

    <el-tree class="expandTree" highlight-current :data="treeData" :props="defaultProps"
                                @node-click="handleNodeClick">
        //重点在类 custom-tree-node 和 :title="node.label" v-text="node.label" 上
        <span slot-scope="{ node, data }" class="custom-tree-node" :title="node.label"
            v-text="node.label">
        </span>
    </el-tree>
    
    //通过自定义树形结构行内容,实现文本过多时数据不显示的问题,现在效果为显示省略号,且鼠标移上去会显示出全部文本内容
    .custom-tree-node {
        width: 100%; 
        overflow: hidden !important; // 溢出部分隐藏
        white-space: nowrap !important; //禁止自动换行
        text-overflow: ellipsis !important; // 使溢出部分以省略号显示
        display: block !important;
        font-size: 20px;
    }
    
    效果图.png

    相关文章

      网友评论

          本文标题:解决el-tree文本内容过多显示不完全问题

          本文链接:https://www.haomeiwen.com/subject/tdqijdtx.html