vant/packages/vant/docs/markdown/vant-use-intro.en-US.md
2021-12-17 20:48:16 +08:00

883 B

Composables

Intro

Vant provide some built-in composition APIs, you can directly use these APIs for development.

Install

Although @vant/use is already included in Vant's dependencies, it is still recommended to install this package explicitly:

# with npm
npm i @vant/use

# with yarn
yarn add @vant/use

# with pnpm
pnpm add @vant/use

Demo

import { useWindowSize } from '@vant/use';

const { width, height } = useWindowSize();

console.log(width.value); // -> window width
console.log(height.value); // -> window height

API List

Name Description
useClickAway Triggers a callback when user clicks outside of the target element
useCountDown Used to manage the countdown
useToggle Used to switch between true and false