Vue3---Vue3项目切换(设置)路由模式
history模式:在路由index.js文件中导入 createWebHistory
import { createRouter, createWebHistory } from ‘vue-router’
import Home from ‘../views/Home.vue’const routes = [
{path: '/',
name: 'Home',
component: Home
},
{path: '/about',
name: 'About',
component: () => import('../views/About.vue')
}
]const router = createRouter({
history: createWebHistory(process.env.BASE_URL),
routes
})export default router
hash模式:在路由index.js文件中导入 createWebHashHistory
import { createRouter, createWebHashHistory } from ‘vue-router’
import Home from ‘../views/Home.vue’const routes = [
{path: '/',
name: 'Home',
component: Home
},
{path: '/about',
name: 'About',
component: () => import('../views/About.vue')
}
]const router = createRouter({
history: createWebHashHistory(process.env.BASE_URL),
routes
})export default router
还没有评论,来说两句吧...