关于-elementui-的隐藏组件elscrollbar

虽然在官方文档中没有给出这个组件,但是在源码中是有的。所以我们可以直接使用:

<el-scrollbar></el-scrollbar>

但是我们需要微调一下样式,两种情况的演示代码如下:

  • 已知内容高度
<div style='height:800px'>
<el-scrollbar class='page-component__scroll'></el-scrollbar>
<div>
<style>
.page-component__scroll{
    height: 100%;
}
.page-component__scroll .el-scrollbar__wrap {
    overflow-x: auto;
}
<style>
  • 高度由内容撑开
<html>
    <body>
        <div style='height:100%'>
            <el-scrollbar class='page-component__scroll'></el-scrollbar>
        <div>
    </body>
</html>

<style>
html,body{
    height:100%
    overflow:hidden; /*有效防止在页面进行手动刷新时显示内置滚动条*/
}
.page-component__scroll{
    height: 100%;
}
.page-component__scroll .el-scrollbar__wrap {
    overflow-x: auto;
}
<style>

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理