hash模式下
yarn serve之后启动项目
`
http://localhost:8080/zh/#/index
`
此路径可以直接访问
因为项目要求 必须要有 zh路径
但是因为要干掉# 跟pc的统一起来 因此要改成history模式
改成history模式之后
再次启动项目 打开浏览器就是
`
http://192.168.1.197:8080/zh/
`
只显示 头部 跟 footer 中间的内容没有了
但是如果手动改成
`
http://192.168.1.197:8080/index
`
页面正常访问
vue.config.js中配置了
`
publicPath:"/zh",
`
期望解决这个问题
改成histroy模式之后 可以直接访问
`
http://192.168.1.197:8080/zh/index
`
router.js的路由配置
`
{
path: '/index',
name: 'Index',
component: Index
},
{
path: '/search',
name: 'Search',
component: Search
},
{
path: '/dentailbase',
name: 'Dentailbase',
component: Dentailbase
},
{
path: '/newscenter',
name: 'Newscenter',
component: Newscenter,
meta:{
keepAlive:true
}
},
{
path: '/newsdentail',
name: 'Newsdentail',
component: Newsdentail
},
{
path: '/activelist',
name: 'Activelist',
component: Activelist,
meta:{
keepAlive:true
}
},
{
path: '/activelistdentail',
name: 'Activelistdentail',
component: Activelistdentail
},
{
path: '/intertclasslist',
name: 'Intertclasslist',
component: Intertclasslist,
meta:{
keepAlive:true
}
},
{
path: '/contactus',
name: 'Contactus',
component: Contactus
},
{
path: '/intertclassdentail',
name: 'Intertclassdentail',
component: Intertclassdentail,
redirect:'/intertclassdentail/description',
children:[
// 课程说明
{
path:'description',
component:Description
},
// 课程视频
{
path:'video',
component:Video
},
// 课程说明
{
path:'comment',
component:Comment
},
]
},
{
path: '/videodentail',
name: 'Videodentail',
component: Videodentail
},
{
path: '/cooperationexchange',
name: 'Cooperationexchange',
component: Cooperationexchange,
meta:{
keepAlive:true,
}
},
{
path: '/cooperationdentail',
name: 'Cooperationdentail',
component: Cooperationdentail
},
{
path: '/login',
name: 'Login',
component: Login
},
{
path: '/messagelogin',
name: 'Messagelogin',
component: Messagelogin
},
{
path: '/forgotPwd',
name: 'ForgotPwd',
component: ForgotPwd
},
`