Reputation: 247
my last vue-router components load normally when i click on the menu links, but when I share a link or refresh a page, components doesn't render. I don't know what might be a problem because it only happens with a last route. Here is a link : https://www.hvarboating.com/speed-boat-hire-hvar-flyer747
my router:
import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)
export const routes = [
{
path: '/',
name: 'Home',
component: () => import(/* webpackChunkName: "about" */ '../views/Home')
},
{
path: '/blue-caves-croatia',
name: 'GroupToursDetails',
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () => import(/* webpackChunkName: "about" */ '../views/GroupToursDetails')
},
{
path: '/boat-tours',
name: 'BoatTours',
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () => import(/* webpackChunkName: "about" */ '../views/BoatTours')
},
{
path: '/hvar-boat-rental',
name: 'BoatRentals',
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () => import(/* webpackChunkName: "about" */ '../views/BoatRentals')
},
{
path: '/from-split-to-Hvar-transfer',
name: 'BoatTransfers',
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () => import(/* webpackChunkName: "about" */ '../views/BoatTransfers')
},
{
path: '/hvar-weather',
name: 'Weather',
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () => import(/* webpackChunkName: "about" */ '../views/Weather')
},
{
path: '/frequently-asked-questions',
name: 'Faq',
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () => import(/* webpackChunkName: "about" */ '../views/Faq')
},
{
path: '/contact',
name: 'Contact',
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () => import(/* webpackChunkName: "about" */ '../views/Contact')
},
{
path: '/:id',
meta: {
sitemap: {
slugs: [
'blue-cave-tour-from-hvar',
'best-beaches-in-hvar-private',
'zlatni-rat-brac-island',
'boat-party-tour'
]
}
},
name: 'details',
props:true,
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () => import(/* webpackChunkName: "about" */ '../views/PrivateToursDetails')
},
{
path: '/:id',
meta: {
sitemap: {
slugs: [
'speed-boat-hire-hvar-flyer747',
'luxury-boat-hire-hvar-tornado38',
]
}
},
name: 'rentals',
props:true,
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () => import(/* webpackChunkName: "about" */ '../views/BoatRentDetails')
},
]
const router = new VueRouter({
scrollBehavior() {
return {x: 0, y: 0}
},
mode: 'history',
base: process.env.BASE_URL,
routes,
})
export default router
Upvotes: 0
Views: 1424
Reputation: 1201
Your two last routes have the same path /:id
so if you switch the route by the route name it works fine, but when you refresh or use a link, it doesn’t know which route you want to use and therefor can’t render the component.
The solution: use unique path for each route
Upvotes: 1