今天看啥  ›  专栏  ›  隐市之人

vue-router使用history模式后nginx相关配置

隐市之人  · 简书  ·  · 2019-11-21 07:20

// todo: 学完nginx,对其有更深了解后再来补充

default.conf
root /usr/share/nginx/html;
# Vue路由模式为history需添加的配置
location / {
# if (!-e request_filename) { # rewrite ^(.*) /index.html?s=$1 last;
# break;
# }

    index  index.html;
    try_files $uri $uri/ /xbootAdmin/index.html;
}

vue.config.js
// 打包时的公共路径
publicPath: process.env.NODE_ENV === 'production' ? '/xbootAdmin/': '/',

router/index.js
// 路由配置
const RouterConfig = {
// nginx部署目录
base: '/xbootAdmin/',
mode: 'history',
routes: routers
};




原文地址:访问原文地址
快照地址: 访问文章快照