可直接使用<el-scrollbar></el-scrollbar>
组件,将需要滚动的内容包在里面。注意要设置el-scrollbar及他外层的高度,以及组件里.el-scrollbar__wrap{
overflow-x: hidden;
}
<template>
<div >
<el-drawer title="查看预览" :visible.sync="DialogShow" direction="rtl" size="80%" >
<el-scrollbar class="scrollbar">
<div style="background-color: #dcdcdc;padding: 20px 0;">
<!--标题-->
<h1 style="text-align: center;">{{form.title}}</h1>
<!--发布时间和作者-->
<div style="display: flex;justify-content: space-between;margin: 0 20px;">
<span>发布时间:{{form.createTime}}</span>
<span>作者:{{form.author}}</span>
</div>
</div>
<!--正文-->
<pre class="preClass" v-html="form.content"></pre>
</el-scrollbar>
</el-drawer>
</div>
</template>
<script>
export default {
name:'viewPreview',
props: {
form:{
type: Object,
default: function () {
return { }
}
}
},
data() {
return {
DialogShow:true
}
},
methods: { },
mounted(){ },
}
</script>
<style scoped>
.scrollbar{
height: calc(100% - 100px);
}
.scrollbar /deep/ .el-scrollbar__wrap{
overflow-x: hidden;
}
</style>