你可以给外层的 div 元素添加 overflow-y: auto; 样式,这样就能为元素添加一个垂直滚动条。修改后的代码如下所示:

<div class='leftsearch min-w-240px' style='width:240px; overflow-y: auto;'>
    <el-form ref='queryFormRef' :model='queryParams' label-position='right' label-width='90px'>
        <div class='flex justify-between'>
            <el-row>
                <!-- highlight-current 当前节点高亮 -->
                <el-tree :data='treeData' :props='defaultProps' node-key='categoryId'
                    :highlight-current='highlightCurrent' default-expand-all @node-click='handleClick' />
            </el-row>
        </div>
    </el-form>
</div>

添加了 overflow-y: auto; 样式后,当内容超过容器高度时会自动显示垂直滚动条。


原文地址: https://www.cveoy.top/t/topic/pamT 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录