I created a new vue project from @vue/cli $> vue create my-project
, activated the Typescript option and router option, and upgraded to vue3 beta with $>vue add vue-next
.
Now, $>npm run serve
fails with
ERROR in /home/auser/dev/my-project/src/router/index.ts(1,10):
1:10 Module '"../../node_modules/vue-router/dist/vue-router"' has no exported member 'RouteConfig'.
> 1 | import { RouteConfig, createRouter, createWebHistory } from 'vue-router';
| ^
2 | import Home from '../views/Home.vue'
The entire file is not that long, and RouteConfig is used later on:
//index.ts
import { RouteConfig, createRouter, createWebHistory } from 'vue-router';
import Home from '../views/Home.vue'
const routes: Array<RouteConfig> = [
{
path: '/',
name: 'Home',
component: Home
},
{
path: '/about',
name: 'About',
// 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/About.vue')
}
]
const router = createRouter({
history: createWebHistory(process.env.BASE_URL),
routes
})
export default router
Q: What is the correct type of RouteConfig, which I need for createRouter
?