vueuse
v11.3.0
互動文檔和演示
無縫遷移:為VUE 3和2工作
完全搖晃的樹:只採用您想要的東西,捆綁尺寸
strong類型:用TypeScript編寫,用TS文檔編寫
SSR友好
不需要捆綁機:可通過CDN使用
靈活:可配置的事件過濾器和目標
可選的附加組件:路由器,firebase,rxjs等。
import {uselocalstorage,usemouse,usepreferreddark} from'@vueuse/core'export默認 setup(){//跟踪鼠標positionconst {x,y} = usemouse()//如果用戶在localStorageConst Store = useLocalStorage中使用了Dark them themeconst isdark = usepreferreddark()// persist state蘋果',顏色:'red' ,}),返回{x,y,isdark,store} },},}
有關更多詳細信息,請參閱功能列表或文檔。
在V12.0中,Vueuse不再支持VUE 2。請使用V10.X進行VUE 2支持。
npm i @vueuse/core
添加ons | NUXT模塊
Vite + Vue 3
NUXT 3 + VUE 3
webpack + vue 3
<script src =“ https://unpkg.com/@vueuse/shared”> </script> <script src =“ https://unpkg.com/@vueuse/core”> </script>
它將以window.VueUse
方式接觸到全球
參見貢獻指南
該項目受到以下很棒的項目的啟發。
Streamich/React-使用
U3U/vue-hooks
對數/vue-use-web
Kripod/React-Hooks
感謝Github上的所有貢獻者!