vue3.0 typescript 创建项目,路由RouteConfig 报错 has no exported member ‘RouteConfig‘.ts

vue3.0 typescript 创建项目,路由RouteConfig 报错 has no exported member 'RouteConfig'.ts

提示 ts没有对应RouteConfig

那么什么原因呢

vue3.0 ts 对这个接口已经更改了。

正确写法如下:

import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'

const routes: RouteRecordRaw[] = [
  {
    path: '/',
    name: 'Home',
    component: () => import('../views/Home.vue')
  },
  {
    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

 

 

 

 

 

©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页