修改vue-element-admin的路由模式为browserHistory
1、修改src/router/index.js
const createRouter = () => new Router({
mode: 'history', // require service support
scrollBehavior: () => ({ y: 0 }),
routes: constantRoutes
})
2、修改项目打包路径,一般情况就按默认“/”(vue.config.js)
publicPath: '/',
3、配置nginx
location / {
# XXX 项目所在路径
root XXX;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}