uniapp h5发布之后,刷新导致404

manifest.json

{
    "name" : "chart-mobile",
    "appid" : "__UNI__0A00C1D",
    "description" : "",
    "versionName" : "1.0.0",
    "versionCode" : "100",
    "transformPx" : false,
    /* 5+App特有相关 */
    "app-plus" : {
        "usingComponents" : true,
        "nvueCompiler" : "uni-app",
        "compilerVersion" : 3,
        "splashscreen" : {
            "alwaysShowBeforeRender" : true,
            "waiting" : true,
            "autoclose" : true,
            "delay" : 0
        },
        /* 模块配置 */
        "modules" : {},
        /* 应用发布信息 */
        "distribute" : {
            /* android打包配置 */
            "android" : {
                "permissions" : [
                    "",
                    "",
                    "",
                    "",
                    "",
                    "",
                    "",
                    "",
                    "",
                    "",
                    "",
                    "",
                    "",
                    "",
                    "",
                    "",
                    "",
                    "",
                    "",
                    "",
                    "",
                    ""
                ]
            },
            /* ios打包配置 */
            "ios" : {},
            /* SDK配置 */
            "sdkConfigs" : {}
        }
    },
    /* 快应用特有相关 */
    "quickapp" : {},
    /* 小程序特有相关 */
    "mp-weixin" : {
        "appid" : "",
        "setting" : {
            "urlCheck" : false
        },
        "usingComponents" : true
    },
    "mp-alipay" : {
        "usingComponents" : true
    },
    "mp-baidu" : {
        "usingComponents" : true
    },
    "mp-toutiao" : {
        "usingComponents" : true
    },
    "h5" : {
        "devServer" : {
            "disableHostCheck" : true // 解决 127.0.0.1 指向其他域名时出现“Invalid Host header" 的问题
        },
        "template": "index.html",
        "title" : "集团报表",
        "domain" : "http://bpm.deyi.com.cn",
        "router": {
        "mode": "history", //路由跳转模式,支持 hash|history ,默认 hash
        "base": "/groupMobile/" //应用基础路径,例如,如果整个单页应用服务在 /app/ 下,然后 base 就应该设为 "/app/"
        }
    },
    "uniStatistics" : {
        "enable" : false
    }
}

nginx配置

  location / {
        root /usr/share/nginx/html;
        index  index.html index.htm;
        try_files $uri $uri/ /groupMobile/index.html;  //一定要写上项目的基础路径。除非直接是没有项目基础路径的,把项目里面的文件都直接放到html下的
    }

nginx存放项目的路径 groupMobile是的uniapp项目
/usr/share/nginx/html/groupMobile

nginx的try_files+manifest.json h5.router.mode等于history 就可以解决刷新404

你可能感兴趣的:(uniapp h5发布之后,刷新导致404)