zoukankan      html  css  js  c++  java
  • 打包后页面空白,刷新404

     
     

    项目的入口文件index.html直接在服务器访问地址的根目录下,即项目独占一个端口

    vue中配置保持不变
    nginx中配置如下:
    server {
            listen      8899;
            server_name localhost;
            location / {
    	       try_files $uri $uri/ /index.html;
            }
        }
    

      

     第二种是 针对项目放在子级目录的情况。

     
    # 打包配置 config-index.js 修改路径:
     
    assetsPublicPath: './';

    # 前端路由配置 router.js:

    const router = new VueRouter({
        mode: 'history',
        base: '/hello',
        routes
    })
    这里一定要一个加一个base;与项目子级目录名同步
     

    nginx 配置:
    server {
        listen 8088;
        server_name xxx.com;  # localhost修改为您证书绑定的域名。
    
        
    
        location /hello{
            try_files $uri $uri/ /hello/index.html;
        }
    }
    

    最终访问xxxxx:8088/hello

    
    

    一个nginx 配置多个端口,多个子域名

        server {
              listen 8082;
              listen 8088;
              server_name localhost;  # localhost修改为您证书绑定的域名。
    
            location /hello {
                try_files $uri $uri/ /hello/index.html;
            }
             location /hello2 {
                try_files $uri $uri/ /hello2/index.html;
            }
    

      

     

  • 相关阅读:
    两种方法生成随机字符串
    cmd命令总结
    NOI前乱写
    多校模拟9
    字符串 口胡
    HEOI2020游记
    省选模拟104
    省选模拟103
    省选模拟102
    省选模拟101
  • 原文地址:https://www.cnblogs.com/lan-cheng/p/12127620.html
Copyright © 2011-2022 走看看