赞
踩
import { createRouter, createWebHistory, createWebHashHistory } from 'vue-router' import index from '../views/index.vue' const routes = [{ path: '/', name: 'index', component: index, children: [{ path: 'home', //首页 name: 'home', component: () => import ('../views/home.vue') }, ] }, { path: '/login',//登录 name: 'login', component: () => import ('../views/login.vue') }, { path: '/register', //注册 name: 'register', component: () => import ('../views/register.vue') }, ] const router = createRouter({ history: createWebHashHistory(process.env.BASE_URL), routes }) export default router
路由要部署到服务器上的话,需要注意的是,
必须是哈希模式,不能是历史模式.
记得导入createWebHashHistory,不然,不成功
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。