贵阳专业网站建设公司哪家好,wordpress上传的文件在哪,重庆最新消息今天封城了,网页设计师培训费用预算图因为没有域名#xff0c;所以用路径来作区分#xff0c;
主项目#xff1a;直接根路由访问该项目#xff0c;与正常配置无任何差别从项目#xff1a;此处设置/new路径#xff0c;为从项目#xff0c;所有从项目访问路径均要加上/new
①修改Nginx配置文件
Nginx 配置文…
因为没有域名所以用路径来作区分
主项目直接根路由访问该项目与正常配置无任何差别从项目此处设置/new路径为从项目所有从项目访问路径均要加上/new
①修改Nginx配置文件
Nginx 配置文件如上所示
server {listen 80;server_name localhost;location / {root html/;index index.html index.htm;try_files $uri $uri/ /index.html;}location /new {alias html/new/;index index.html index.htm;try_files $uri $uri/ /new/index.html;}
}
②修改从项目
主要就是在项目中增加一个baseUrl就是你自定义的路径我这里是new
vue.config.js 增加 publicPath: /new/ module.exports {lintOnSave: false, // 关闭eslintpublicPath: /new/,devServer: {port: 80, // 端口号的配置open: true, // 自动打开浏览器proxy: {/api: {target: http://127.0.0.1:8080/,changeOrigin: true,pathRewrite: {^/api: /}},},}
} index.html 增加 meta base/new/ !DOCTYPE html
html langenheadmeta charsetutf-8meta base/new/meta http-equivX-UA-Compatible contentIEedgemeta nameviewport contentwidthdevice-width,initial-scale1.0link relicon href% BASE_URL %favicon.ico/head
router/index.js 增加 base: /new/ const router new VueRouter({base: /new/,routes: globalRoutes
}) 还有一点
在从项目中上述地方均改了以后对于静态文件使用url请求的也要手动增加/new路径要不然打开项目以后会 找不到资源。 例如我这里请求前端的地图资源数据我是用前端地址位置访问的如果此处不改上线后就会找不到静态资源 其实还有个办法就是上线以后哪个资源找不到就回去改哪个毕竟项目大可能也改不全比如上线了网站背景图没刷出来F12查看找不到对一下路径发现错了回去改即可 if (!this.mapData[arg.name]) {const ret await axios.get(http://99.199.199.99:80 /new/static/map/country/ arg.name .json)this.mapData[arg.name] ret.datathis.$echarts.registerMap(arg.name, ret.data)
} 改了配置文件和前端代码docker重启Nginx就能正常访问了记得两个前端项目都用同一个接口哈