You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何阻止Quasar的下拉列表随页面滚动?

解决Quasar Q-Select下拉列表随页面滚动偏移的问题

针对你遇到的Q-Select展开后下拉列表随页面滚动而偏离下拉框的问题,有几种直接的解决方式:

方法1:给滚动容器添加相对定位

如果表单放在滚动容器内,给该容器添加position: relative样式,让Q-Select的下拉菜单相对于这个容器定位,滚动时下拉列表会跟着下拉框同步移动:

.form-scroll-container {
  position: relative;
  overflow-y: auto;
  /* 根据需求设置容器高度等样式 */
}

确保Q-Select处于该容器内部即可生效。

方法2:使用Q-Select的attach属性

通过attach属性将下拉菜单挂载到指定的滚动容器上,强制下拉菜单相对于该容器定位:

<q-select 
  filled 
  v-model="model" 
  :options="options" 
  label="Filled"
  attach=".form-scroll-container"
/>

注意目标容器(.form-scroll-container)必须设置position: relative,否则attach属性无法正常工作。

方法3:全局滚动场景下使用fixed菜单属性

如果是页面全局滚动而非容器内滚动,可设置menu-props="{ fixed: true }",让下拉菜单以固定定位绑定到下拉框位置,不会随页面滚动偏移:

<q-select 
  filled 
  v-model="model" 
  :options="options" 
  label="Filled"
  :menu-props="{ fixed: true }"
/>

内容的提问来源于stack exchange,提问作者Maryam Mikog

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.20 11:42:13