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

// 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
};

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容