在App中全局配置getPopupContainer解决antdv中select, time下拉组件下拉时跟随滑动问题

321 阅读1分钟

5c5fd43e05c6c106973a34fafc7245e.png

<template>
  <a-config-provider :locale="locale" :getPopupContainer="getPopupContainer">
    <div id="app" >
      <router-view v-if="isRouterAlive" :key="$route.fullPath" />
    </div>
  </a-config-provider>
</template>
  methods: { 
     getPopupContainer(el, dialogcontext) {
      if (el) {
        return el.parentNode;
      } else {
        return document.body;
      }
    },
  },

image.png

总结: 需要在配置中添加属性:getPopupContainer="getPopupContainer"

可参考文档解释说明 : www.antdv.com/components/…