Navigation Router
The only difference in Framework7-Vue is that in Vue.js we are already composing our application with Vue components, so we need to map our Pages (Vue components) to the routes. It can be done by passing Vue component in property of the route. Here’s a basic example:
<!-- home.vue -->
<template>
<f7-page name="home">
<f7-navbar title="Home"></f7-navbar>
<!-- Page content -->
...
<f7-link href="/about/">About Page</f7-link>
<f7-link href="/login/">Login Page</f7-link>
</f7-page>
</template>
<script>
</script>
<!-- about.vue -->
<template>
<f7-navbar title="About"></f7-navbar>
<!-- Page content -->
</f7-page>
</template>
<script>
export default {}
</script>
<!-- login.vue -->
<template>
<f7-page name="login">
<!-- Page content -->
</f7-page>
</template>
<script>
export default {}
Check the full to know about all possible routes options, how to use Nested Routes, and Routable Modals.
First of all, all route params will be automatically passed as props to component, e.g.
So if we navigate by /blog/45/comments/122/
URL, then the following data will be passed to props:
{
postId: '45',
commentId: '122',
}
And finally, props can be passed dynamically to route component when we navigate with API:
this.$f7router.navigate('/some-page/', {
props: {
foo: 'bar',
bar: true,
}
})
With Webpack it is possible to load page components on demand, it is possible with F7’s async route, for example:
<f7-link @click="$f7router.navigate('/about/')">About</f7-link>
Please note, that $f7route
and $f7router
component properties are only available inside of custom page components that you load according to routes. In parent components (like in View, or where you init your Vue app instance) and in child components they are not accessible. So in this case use access to initialized , e.g. $f7.views.main.router