Vue中config/index.js
文件中的proxyTable
设置与index.html
中<base href="xxx">
标签地址一致会导致刷新404问题(即使是dev调试状态下)。
例如如下设置将会导致前台调试时刷新404错误:
错误范例:
config/index.js中
dev: {
assetsSubDirectory: 'static',
assetsPublicPath: '/',
proxyTable: {
'/GeoProblemSolving': {
target: 'http://localhost:8081',
changeOrigin: true,
pathRewrite: {
'^/GeoProblemSolving': '/'
}
}
},
index.html中
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<base href="/GeoProblemSolving/">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>Geo-problemSolving</title>
</head>
<body>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>
解决办法是避免proxyTable
中的代理参数与<base>
标签内容一致。