已解决,修改后端路由404配置即可。
1.前端环境预览正常,基于本地node服务
vue路由配置如下,开启了h5 history.pushState()路由,即mode: 'history'。在前端预览的时候正常,删掉了URL中的#符号。
Vue.use(Router)
const routes = [
{
path: '/score',
component: resolve => {
require(['../score/scoreList.vue'], resolve);
}
},
{
path: '/score/list',
component: resolve => {
require(['../score/scoreList.vue'], resolve);
}
},
{
path: '/score/Add',
component: resolve => {
require(['../score/scoreAdd.vue'], resolve);
}
},
{
path: '/score/Detail',
component: resolve => {
require(['../score/scoreDetail.vue'], resolve);
}
}
];
export default new Router({
mode: 'history',
history: true,
saveScrollPosition: true,
routes: routes
});
2.代码同步到后端指定文件夹后路由出错
2.1后端路预览a.com/score的时候正常,但是其他组件访问都是404。
2.2如果前端路由不删除#号,后端访问所有页面都正常。后端是koaJs(node服务)
求大神指导迷津,是我前端组件路由配置不对?还是需要修改后端路由?
相关分类