0.0.2 • Published 3 years ago

@bisquit/vue-router-composable v0.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

vue-router-composable

Use vue router with composition API in Vue 2

Installation

npm install @bisquit/vue-router-composable
# or
yarn add @bisquit/vue-router-composable

Usage

Before using this package, you should install and setup @vue/composition-api.

useRouter()

import { useRouter } from '@bisquit/vue-router-composable';

export default {
  setup() {
    const router = useRouter();

    const onClick = () => {
      router.push('/');
    };
  },
};

useRoute()

import { useRoute } from '@bisquit/vue-router-composable';

export default {
  setup() {
    const route = useRoute();

    // `route` is a ref, so use with `unref` or `.value`
    const { query } = route.value;
    doSomething(name: query.name);
  },
};

License

MIT