小李看前端 2021-06-15 16:30 采纳率: 42.9%
浏览 403
已结题

nginx配置vue项目 统一端口转发vue不同的路由

项目部署时 nginx 配置vue项目统一端口转发vue不同的路由

求各位大神出个方案

环境试linux  

项目使用的jeecg-boot框架

目前的配置时这样子的,

 


#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    gzip on;
    gzip_min_length 1k;
    gzip_comp_level 9;
    gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
    gzip_vary on;
    gzip_disable "MSIE [1-6]\.";
    server{
        listen       80;
        location / {
             root   /home/web/yaoyuan;
            try_files $uri $uri/ /index.html;
            index  index.html index.htm;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

    }
    server{
        listen       80;
        server_name admin.xxxxxx.xx;
        location / {
            root   /home/web/xxxx;
            try_files $uri $uri/ /index.html;
            index  index.html index.htm;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;    
        }
    }

   server{
        listen       90;
        server_name www.xxxx.xxx;
        location / {
            #admin.xxxx.xxx/shoppingMall/Index/Index
            proxy_pass http://127.0.0.1/shoppingMall/Index/Index;
        }
        
        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
           proxy_pass http://admin.xxx.xxxx;
        }

        location ~* .(js|css)$ {
        proxy_pass http://admin.xxxxx.xxxx;
        }

        location ~ .*\.(js|css)?$
        {
            proxy_pass http://admin.xxxxxx.xxxxxx;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

    }

}
  • 写回答

1条回答 默认 最新

  • 王大师王文峰 企业官方账号 2021-06-15 16:37
    关注

    看一下jeecg-boot官方文档:望采纳,谢谢

    vue路由带参总结
    1. params
    <router-link :to="{name:'test', params: {id:1}}">
    配置路由格式要求: path: "/test/:id"
    js参数获取:this.$route.params.id
    
    2.query
    <router-link :to="{name:'test', query: {id:1}}">
    配置路由:无要求
    js参数获取:this.$route.query.id
    
    备注:
    router-link是html写法,JS中语法如下:
    this.$router.push({name:'test',query: {id:'1'}})
    this.$router.push({name:'test',params: {id:'1'}})
    评论

报告相同问题?

悬赏问题

  • ¥15 使用C#,asp.net读取Excel文件并保存到Oracle数据库
  • ¥15 C# datagridview 单元格显示进度及值
  • ¥15 thinkphp6配合social login单点登录问题
  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 虚心请教几个问题,小生先有礼了
  • ¥30 截图中的mathematics程序转换成matlab