猿问

vue-cli3.0多页配置时,本地刷新后,找不到路由,该怎么配置?

发现vue-cli脚手架新出了个3.0里面有多页配置项,对文档来试着配置,可以访问每个页面,但是发现刷新时,对应页面的路由都找不到,代码如下
//vue.config.js
module.exports={
baseUrl:process.env.NODE_ENV==='production'
?'/ems/'
:'/ems/',
pages:{
admin:{
entry:'src/views/admin/main.js',
template:'public/admin.html',
filename:'admin/index.html',
},
school:{
entry:'src/views/school/main.js',
template:'public/school.html',
filename:'school/index.html',
}
}
}
//admin.routes.js
importVuefrom'vue'
importRouterfrom'vue-router'
importHomefrom'@/views/admin/Home.vue'
importLayoutfrom'@/components/layout-admin'
Vue.use(Router)
constroutes=[
{
path:'/',
redirect:{name:'admin'},
},
{
path:'/admin',
name:'admin',
component:Layout,
redirect:{name:'home'},
children:[
{
path:'home',
name:'home',
component:Home
},
{
path:'about',
name:'about',
component:()=>import('./../views/admin/About.vue')
}
]
}
]
exportdefaultnewRouter({
mode:'history',
base:process.env.BASE_URL,
routes
})
当通过访问/ems/admin路由来访问/ems/admin/home是可以的,但是直接访问/ems/admin/home是访问不到的,有哪位指导下为啥?
人到中年有点甜
浏览 1339回答 2
2回答
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答