前提问题:使用el-popover弹出框,el-popover在element plus中规定宽度属性,最小宽度是150
在本身属性上设置小于150px的宽度并未生效,使用穿透,deep修改.el-popover.el-popper的宽度也未生效
解决过程:因为el-popover是和app一个层级,在body下的,所以以上两种方式都不能够修改宽度,使用el-popover本身属性popper-class,设置自定义样式类,去除<style>的scoped,设置自定义类的样式为min-width: 120px!important;具体宽度根据个人需要设定,如果是设定150px以上的,不用这些设置,直接使用el-popover本身属性width即可设定
解决结果:
html部分
<el-popover :visible="data.isShowMenu" placement="right" trigger="click" popper-class="customPopper">
<p @click.stop="()=>importLineData(data)" class="popoverFont">
<span class="iconfont icon-daoru" style="margin-right:10px;color:#2387F0;"/>
<span>导入</span>
</p>
<p v-show="node.data.type > 6" class="popoverFontB">
<span class="iconfont icon-tianxie" style="margin-right:10px;color:#2387F0;"/>
<el-badge is-dot>数据变更</el-badge>
</p>
<template #reference>
<span @click.stop="()=>showMenu(data)" class="iconfont icon-24gf-ellipsis"/>
</template>
</el-popover>
css部分
<style lang="scss">
.customPopper {
min-width: 120px!important;
}
</style>