npm install @vue/babel-preset-jsx @vue/babel-helper-vue-jsx-merge-props --save //在.babelrc配置 { "presets": ["@vue/app","@vue/babel-preset-jsx"] }
报错:Duplicate declaration "h" (This is an error on an internal node. Probably an internal error.)
解决方法css
//在.babelrc配置,删掉"@vue/babel-preset-jsx" { "presets": ["@vue/app"] }
Proxy error: Could not proxy request /xxx/list?pageNo=1&pageSize=10 from localhost:8080 to http://x.x.x.x:8108 (ECONNRESET). {"code":"200","msg":"请求成功","success":true,"data":{"total":107,"list":[{...},...,{"id":132,..."name":"帐户�Proxy error: Could not proxy request /eventNotifyPerson/list?pageNo=1&pageSize=10 from localhost:8080 to http://172.16.21.237:8108 (ECONNRESET).
ECONNRESET (Connection reset by peer): A connection was forcibly closed by a peer. This normally results from a loss of the connection on the remote socket due to a timeout or reboot. Commonly encountered via the http and net modules.
问题排查:html
后端问题排查,wireshark抓包发现http传输,数据包没传输完,链接就断开了。前端
尝试在前端请求头中加Connection: Keep-Alive。一开始尝试在axios请求中加,添加方式以下:vue
axios.defaults.headers['Connection'] = 'Keep-Alive'
控制台报错:[图片]
换另一种方式:[图片]
浏览器看到是:Connection: Keep-Alive
但抓包中显示:connection: close,难道是加的不对,没生效?又参考(axios的api文档),在接口的config中添加,结果仍是同样。
查找资料HTTP Keep-Alive模式,发现浏览器keep-alive机制以下:
查看抓包中的http请求是1.1版本,理应会是默认开启keep-alive的,随后找后端确认,原来虽然浏览器发出的时候,keep-alive是默认开启的,但通过webpack的代理转发,keep-alive被关闭了,代理将这个值设置为了close,随后查找资料,深刻分析vue的webpack代理设置:vue.config.js中的devServer.proxy实际使用的是http-proxy-middleware中间件,查看配置项,修改devServer以下:
查看wireshark抓包内容,确认proxy的Connection: Keep-Alive,添加成功。
再次访问后端接口,接口200,数据正常,问题修复。node