vue本地history 刷新后页面空白问题

修改hash为history
在这里插入图片描述

添加 publicPath: '/',
在这里插入图片描述
项目是调了不同得服务器 所以 做了代理
在这里插入图片描述

module.exports = {
    
    
  //...
  devServer: {
    
    
    proxy: {
    
    
      '/': {
    
    
        target: 'http://localhost:3000',
        // 只需要添加该方法,然后当请求的是html,则重定向到index.html
        bypass: function (req, res, proxyOptions) {
    
    
          if (req.headers.accept.indexOf('html') !== -1) {
    
    
            console.log('Skipping proxy for browser request.');
            return '/index.html';
          }
        },
      },
    },
  },
};

感谢树洞ROBOT

猜你喜欢

转载自blog.csdn.net/wzwzwz555/article/details/129798717