Skip to content
Discussion options

You must be logged in to vote
/**
 * 修复 wujie 无界微前端框架下,naive-ui / vueuc 弹出层位置翻转的问题。
 *
 * 根因:vueuc 通过 #v-binder-view-measurer(一个 position:fixed 的全屏 div)
 * 来测量视口边界。在 wujie 子应用沙箱中,若 body 被隐藏/尺寸异常,
 * getBoundingClientRect() 返回零值 → 底部空间计算为负数 → 触发 flip。
 *
 * 修复策略(三层防护):
 * 1. 在 document.body 中抢先创建 #v-binder-view-measurer,覆盖其 getBoundingClientRect
 * 2. 用 MutationObserver 监听 body,若 vueuc 自行重新创建了 measurer,也覆盖之
 * 3. 同时接管 Element.prototype.getBoundingClientRect 中对 measurer 的调用作为最终兜底
 */

function getViewportSize(): { width: number; height: number } {
  try {
    if (window.parent && window.parent !== window) {
      const pw = window.parent;
      if (pw.innerWidth > 0) return { width: pw.innerWidth, height: pw.innerHeight…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by karlio66
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant