vue history 模式打包部署在域名的二级目录的配置指南
1. vue-router 路由的文件的配置,根据自己部署的二级目录填写
|
1
2
3
|
export default new VueRouter({ mode:"history", base:"/web", |
2.在vue.config.js配置文件(如果没有新建一个,项目根目录下)
注意: baseUrl 从 Vue CLI 3.3 起已弃用,请使用publicPath。
|
1
2
3
|
module.exports = { publicPath:"/web"} |
3.在入口文件中index.html 的head 标签内加入
<meta base ="/web/">
4.最后就是部署配置,以nginx 为例
|
1
2
3
4
5
6
7
8
|
server { listen 80; server_name localhost; root /home/wwwroot/; location /web { try_files $uri $uri/ /web/index.html; }} |
到此,配置和部署已经完成了,将打包好的前端静态资源放在域名指定的根目录下的二级(多级目录配置同上)录即可,

浙公网安备 33010602011771号