I’m having no end of problems getting routing to work with a Vue app I’m trying to prototype.
-
How to disable animation for one or more routes.
I’m trying to have some views appear in place, rather than perform an animated slide transition. In previous iterations I could callthis.$router.directionOverride = 'root';
before navigating, but this no longer appears to be valid. How can I set an animation transition on a per-view basis? -
How to set a view as root?
I’m trying to have some views set as root, so that they replace the navigation history and eg don’t ever show a back button. I’ve tried arouter.beforeEach
function which navigates to the first view in the history and then performs a route.replace with the new view, but this doesn’t seem to work. How can I set a route (such as chosen from a side menu) as being the root of the navigation stack?
And some environment info;
"@ionic/vue": "^5.4.0-dev.202008312030.a6d6d90",
"@ionic/vue-router": "^5.4.0-dev.202008312030.a6d6d90",
"vue": "^3.0.0-0",
"vue-router": "^4.0.0-0"
Router Setup
import { createRouter, createWebHistory } from '@ionic/vue-router';
import { RouteRecordRaw } from 'vue-router';
const routes: Array<RouteRecordRaw> = [
{
path: '/',
component: () => import('@/views/Home.vue'),
},
{
path: '/categories/',
component: () => import('@/views/Categories.vue'),
},
{
path: '/categories/:categoryId',
component: () => import('@/views/Category.vue'),
},
{
path: '/people/',
component: () => import('@/views/People.vue'),
},
{
path: '/people/:personId',
component: () => import('@/views/Person.vue'),
},
]
const router = createRouter({
history: createWebHistory(process.env.BASE_URL),
routes
})
App view
<template>
<ion-app>
<ion-menu content-id="main-content" type="overlay">
<ion-content class>
<ion-menu-toggle>
<ion-button fill="clear">
<ion-icon name="close"></ion-icon>
</ion-button>
</ion-menu-toggle>
<ion-list>
<ion-menu-toggle>
<ion-item mode="md" lines="none" @click="goToPage('/categories')">
<ion-label>Categories</ion-label>
</ion-item>
<ion-item mode="md" lines="none" @click="goToPage('/people')">
<ion-label>People</ion-label>
</ion-item>
</ion-menu-toggle>
</ion-list>
</ion-content>
<ion-router-outlet id="main-content" />
</ion-app>
</template>