解决WebSocketClient.js?5586:16 WebSocket connection to ‘ws://10.51.40.191:8081/ws‘ failed:

解决WebSocketClient.js?5586:16 WebSocket connection to ‘ws://10.51.40.191:8081/ws‘ failed:_第1张图片
如果出现以上问题,是因为你跨域,所以需要配置代理
在vue.config.js配置如下代码即可解决:
代码:

const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
  devServer: {
    proxy: 'http://127.0.0.1:3007'
  },
  transpileDependencies: true
})

解决WebSocketClient.js?5586:16 WebSocket connection to ‘ws://10.51.40.191:8081/ws‘ failed:_第2张图片

解决WebSocketClient.js?5586:16 WebSocket connection to ‘ws://10.51.40.191:8081/ws‘ failed:_第3张图片

你可能感兴趣的:(javascript,websocket,vue.js)