Skip to content

Latest commit

 

History

History
56 lines (44 loc) · 1.54 KB

README.md

File metadata and controls

56 lines (44 loc) · 1.54 KB

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 are
used 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

  1. WeChat: cai_fanwei
  2. QQ Group: 663286147
  3. E-mail: [email protected]