主要原因是:项目配置的路由与服务器请求路径不一致。
1、检查配置
├── config/
│ ├── index.js # main project config
2、选项assetsPublicPath
assetsPublicPath: '/',
build.assetsPublicPath
This should be the URL path where your
build.assetsRoot
will be served from over HTTP. In most cases, this will be root (/
). Only change this if your backend framework serves static assets with a path prefix. Internally, this is passed to Webpack asoutput.publicPath
.
3、下列情况会报此错误
- 线上访问路径:http://www.xxx.com/abc/
- 开发访问路径:http://IP:端口/
- assetsPublicPath: '/',
- /src/router/index.js配置
export default new Router({
mode: 'history',
base: '/abc/',
解决方法,修改assetsPublicPath选项
assetsPublicPath: '/abc/',