vue项目的默认加载路径是localhost:8080/,如果要改为localhost:8080/index怎么办呢?可以用路径的重定向来实现:
在src/router/index.js文件中在 path:"/" 后添加 redirect:"/index" 来重定向:
export default new Router({
routes: [
{
path: '/',
redirect: '/index' // 路由重定向
}
]
})
可以查看官方文档解释:
https://router.vuejs.org/zh/guide/essentials/redirect-and-alias.html#%E9%87%8D%E5%AE%9A%E5%90%91