This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Popper from 'element-ui/lib/utils/popper'; | |
const root = window; | |
// 重写此方法,以解决 body zoom 导致 ElementUI 所有 popper 相关元素错位的问题 | |
// bug 产生原因:因为此方法依赖 `document.documentElement.clientWidth` 和 `document.documentElement.clientHeight` | |
// 而这两个值是 body 缩放之前的宽度和高度,换句话说,这两个值与 `zoom` 无关 | |
// 所以解决方案的思路就是:重写此方法,将这两个值换成能有效获取实际宽高的方式即可 | |
// 我的方案是换成了 `document.body.getBoundingClientRect()` 的 `width` 和 `height` | |
// 但这个逻辑依赖于 `body` 本身的宽高,所以请根据自己的情况换成更合适你的方案食用~ |