这里是什么类型的路由器?
import { RouteRecordRaw } from 'vue-router'
const moduleRoute: Array<RouteRecordRaw> = [
{
path: '/user',
component: () => import('./HomeModule.vue'),
children: [
]
}
]
export default router => {
router.addRoute(moduleRoute)
}
我想要的是可导出路由器的类型
路由器类型为来自'vue-router'的router。你可以这样使用:
import { createRouter, createWebHistory } from 'vue-router';
import type { Router } from 'vue-router';
const router: Router = createRouter({
history: createWebHistory(),
routes: [],
});
这是你的更正代码:
import type { RouteRecordRaw, Router } from 'vue-router';
const moduleRoute: RouteRecordRaw = {
path: '/user',
component: () => import('./YourView.vue'),
children: [],
};
export default (router: Router) => {
router.addRoute(moduleRoute);
};