首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何在Nuxt 3上使用UseScroll

如何在Nuxt 3上使用UseScroll
EN

Stack Overflow用户
提问于 2022-10-14 14:46:01
回答 1查看 69关注 0票数 0

我在我的nuxt 3项目上使用@vueuse的useScroll。但是useScroll似乎不起作用。这是码箱最小重现性

// app.vue

代码语言:javascript
运行
复制
<script setup lang="ts">
const { x:mouseX, y:mouseY } = useMouse()

const el = ref<HTMLElement | null>(null)
const { x, y, isScrolling, arrivedState, directions } = useScroll(el)
</script>

<template>

<div>Mouse pos: {{mouseX}}, {{mouseY}}</div>
<div ref="el"></div>


      <NuxtWelcome /> //inserted to make the page long  so we can scroll
      <div>Scroll po pos: {{x}}, {{y}}</div> // here is the problem both x and y are 0,0 no matter how you scroll

  <NuxtWelcome /> //inserted to make the page long so we can scroll

</template>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-10-14 22:58:03

在我的案例样式overflow:scroll中溢出时,引用的元素需要是可滚动的。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74070972

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档