// router/index.js
export default new Router({
mode: 'history',
base: '/data',
routes: constantRouterMap.concat(asyncRouterMap)
})
// vue.config.js
{
...
publicPath: './',
outputDir: 'dist',
...
}
<div id="app"></div>
<script src="/data/static/icon/iconfont.js"></script>
nginx配置
location / {
root html;
index index.html index.htm;
}
# 访问这个
location ^~ /web-ai/ {
alias html/dist/;
index index.html index.htm;
}
文件路径
history模式,并且每一个都有一个前缀/data,部署之后所有路由懒加载的页面会404,比如
这样是没问题的,但是这样
点击对应页面的时候就是404
http://localhost/data/js/chunk-17662e9e.02b4f0b6.js
publicPath
改为./