@bisquit/vue-router-composable
v0.0.2
Published
Use vue router with composition API in Vue 2
Downloads
9
Readme
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);
},
};