网上找了很久解决方案,都无法解决,其实只要加一个属性即可解决。
场景:
父组件中引入子组件弹窗,弹窗出现后,浏览器右侧出现两个滚动条。
滚动鼠标滚动的是灰色背景。
原因:
鼠标事件被背景body获取 ,而不是被弹窗所获取,因此滚动鼠标触发的是背景的滚动
解决:
为子组件弹窗加入 append-to-body 属性(嵌套的 Dialog 必须指定该属性并赋值为 true)
父组件中引入子组件
<ShowPDF :showSection=sectionShow.show
:title=sectionShow.title
:path=sectionShow.path
@onCloseDialog=sectionCancelDialog>
</ShowPDF>
子组件ShowPDF 弹窗
<el-dialog :title="title" :visible.sync="showSectionDialog"
@close="closeSectionDialog" @open="openSectionDialog"
:close-on-click-modal="false" top="20px"
width="90%" :append-to-body="true">
这是Element官网对Dialog 对话框的一个属性解析,https://element.faas.ele.me/#/zh-CN/component/dialog