修改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