import { createRouter, createWebHashHistory } from 'vue-router' const router = createRouter({ // createWebHistory 路由模式路径不带#号(生产环境下不能直接访问项目,需要 nginx 转发) // createWebHashHistory 路由模式路径带#号 history: createWebHashHistory(), routes: [ { path: '/', redirect: '/home' }, { path: '/home', name: 'home', component: () => import('@/views/Home') }, { path: '/home', name: 'newsContent', component: () => import('@/views/Home') }, { path: '/book/:id', name: 'book', component: () => import('@/views/Book') } ] }) export default router