useWindowScroll
useWindowScroll
リアクティブなウィンドウスクロール
使用法
<script setup lang="ts">
import { useWindowScroll } from '@vueuse/core'
const { x, y } = useWindowScroll()
</script>
<template>
<div>
現在の x, y スクロールを読み取る: {{ x }}, {{ y }}
</div>
<button @click="x = 100">
X を 100 にスクロール
</button>
<button @click="y = 100">
Y を 100 にスクロール
</button>
</template>
© 2019–PRESENT Anthony Fu https://github.com/antfu
※このページは Nuxt.js 公式ドキュメントの翻訳ページです。
公式ドキュメントの該当ページはこちら:
#