遇到这个错误可能是配置跨域服务时的rewrite函数没有返回值
如果你的代码像下面这样:
server:{proxy:{'/api':{target:'http://127.0.0.1:8000',changeOrigin:true,//支持跨域rewrite:(path)=>{path.replace(/^\/api/,'')}}}}
这样就是rewrite函数没有返回值
改正:
server:{proxy:{'/api':{target:'http://127.0.0.1:8000',changeOrigin:true,//支持跨域rewrite:(path)=>path.replace(/^\/api/,'')}}}
或:
server:{proxy:{'/api':{target:'http://127.0.0.1:8000',changeOrigin:true,//支持跨域rewrite:(path)=>{return path.replace(/^\/api/,'')}}}}