vue2-helpers
A util package to use Vue 2 with Composition API easily
110,724
70
| Install | |
|---|---|
npm install vue2-helpers |
|
| Latest Version: | 2.1.1 |
| Vue: | 2 |
| License: | Apache-2.0 |
| Last Updated: | Oct 11, 2022 |
| Links: | GitHub · npm |
Maintainer: ambit_tsai
Vue2 Helpers
A util package to use Vue 2 with Composition API easily.
NOTE:
- vue2-helpers@1 is for vue2.5 and 2.6
- vue2-helpers@2 is for vue2.7
⬇️ Install
npm i -S vue2-helpers
📃 Usage
import { createVuexHelpers } from 'vue2-helpers';
import { useRouter } from 'vue2-helpers/vue-router';
const { useState } = createVuexHelpers<
RootState, RootGetters, RootMutations, RootActions
>();
// Get a reactive and mutable ref object "stateA"
const { stateA } = useState('module', ['stateA']);
const router = useRouter();
router.push('/login');
✨ API
vue2-helpers
| Features | Description |
|---|---|
createVuexHelpers< RootState, RootGetters, RootMutations, RootActions>(): { useState, useGetters, useMutations, useActions} |
The helper methods in return value areused to replace mapState, mapGetters,mapMutations, mapActions |
vue2-helpers/vuex
| Features | Description |
|---|---|
createStore<S>(options: StoreOptions<S>): Store<S> |
|
useStore<S = any>(): Store<S> |
vue2-helpers/vue-router
| Features | Description |
|---|---|
createRouter(options: RouterOptions): Router |
|
onBeforeRouteLeave(leaveGuard: NavigationGuard): void |
|
onBeforeRouteUpdate(updateGuard: NavigationGuard): void |
|
useRoute(): RouteLocationNormalized |
|
useRouter(): Router |
|
router.isReady(): Promise<void> |
☎️ Contact
- WeChat: cai_fanwei
- QQ Group: 663286147
- E-mail: ambit_tsai@qq.com
Related Packages
Version History
| Version | Released | License |
|---|---|---|
| 2.1.1 | Apache-2.0 | |
| 2.1.0 | Apache-2.0 | |
| 2.0.1 | Apache-2.0 | |
| 2.0.0 | Apache-2.0 | |
| 1.2.2 | Apache-2.0 | |
| 1.2.1 | Apache-2.0 | |
| 1.2.0 | Apache-2.0 | |
| 1.1.7 | Apache-2.0 | |
| 1.1.6 | Apache-2.0 | |
| 1.1.5 | Apache-2.0 | |
| 1.1.4 | Apache-2.0 | |
| 1.1.3 | Apache-2.0 | |
| 1.1.2 | Apache-2.0 | |
| 1.1.1 | Apache-2.0 | |
| 1.1.0 | Apache-2.0 | |
| 1.0.0 | Apache-2.0 |
Pre-releases (4)
| Version | Released | License |
|---|---|---|
| 1.1.6-test.4 | Apache-2.0 | |
| 1.1.6-test.3 | Apache-2.0 | |
| 1.1.6-test.2 | Apache-2.0 | |
| 1.1.6-test.1 | Apache-2.0 |