0👍
✅
Why are you using vue.use(createRouter,createWebHistory)
in your router file?
index.js – router directory
import { createRouter, createWebHistory } from 'vue-router'
const routes = [
{
name: 'Home',
component: () => import('../views/homePosts'),
path: '/'
},
{
name: 'writepost',
component: () => import('./views/writePost'),
path: '/writePost'
}
];
const router = createRouter({
history: createWebHistory(),
routes
})
export default router
It will be much healthier if you remove the line you use vue.use(createRouter,createWebHistory)
and import the components in this way. And I believe that this way the problem will be solved.
If you are wondering why we imported the components this way, I suggest you read this source (Lazy Loading).
Source:stackexchange.com