vue 路由设置history模式

126 阅读1分钟

本地404

  • vue.config.js设置publicPathhistoryApiFallback
module.exports = {
    publicPath: '/',
    devServer: {
        historyApiFallback: {
            index: '/' //与Output的publicPath
        },
    }
}

配置后,本地页面刷新ok

线上404

在nginx.conf中添加参数配置:

location / { try_files $uri $uri/ /index.html$args; }