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