VueUse

用于 Vue 2 和 3 的基本 Vue 组合实用程序集。「Collection of essential Vue Composition Utilities for Vue 2 and 3」

Github星跟踪图

🚀 Features

  • 🎪 Interactive docs & demos
  • 🕶 Seamless migration: Works for both Vue 3 and 2
  • Fully tree shakable: Only take what you want, bundle size
  • 🦾 Type Strong: Written in Typescript, with TS Docs
  • 🔋 SSR Friendly
  • 🌎 No bundler required: Usable via CDN
  • 🔩 Flexible: Configurable event filters and targets
  • 🔌 Optional Add-ons: Router, Firebase, RxJS, etc.

🦄 Usage

import { useMouse, usePreferredDark, useLocalStorage } from '@vueuse/core'

export default {
  setup() {
    // tracks mouse position
    const { x, y } = useMouse()

    // is user prefers dark theme
    const isDark = usePreferredDark()

    // persist state in localStorage
    const store = useLocalStorage(
      'my-storage',
      {
        name: 'Apple',
        color: 'red',
      },
    )

    return { x, y, isDark, store }
  }
}

Refer to functions list or documentations for more details.

📦 Install

🎩 From v4.0, it works for Vue 2 & 3 within a single package by the power of vue-demi!

npm i @vueuse/core

Vue 3 Demo: Vite, Webpack / Vue 2 Demo: Vue CLI

From v6.0, VueUse requires vue >= v3.2 or @vue/composition-api >= v1.1

CDN

<script src="https://unpkg.com/@vueuse/shared"></script>
<script src="https://unpkg.com/@vueuse/core"></script>

It will be exposed to global as window.VueUse

🧱 Contribute

See the Contributing Guide

🌸 Thanks

This project is heavily inspired by the following awesome projects.

And thanks to all the contributors on GitHub!

👨‍🚀 Contributors

Financial Contributors on Open Collective

📄 License

MIT License © 2019-PRESENT Anthony Fu

概览

名称与所有者vueuse/vueuse
主编程语言TypeScript
编程语言JavaScript (语言数: 6)
平台Linux, Mac, Web browsers, Windows
许可证MIT License
发布数294
最新版本名称v10.9.0 (发布于 2024-02-27 12:53:58)
第一版名称0.0.2 (发布于 )
创建于2019-12-14 06:44:59
推送于2024-05-11 19:28:57
最后一次提交
星数18.8k
关注者数127
派生数2.4k
提交数3k
已启用问题?
问题数1562
打开的问题数129
拉请求数1540
打开的拉请求数58
关闭的拉请求数494
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?
去到顶部