vue WebSocket connection to ‘ws://192.168.31.221:8080/ws‘ failed:

如果是vue2 那么在 vue.config.js里面加 client 对象

const { defineConfig } = require("@vue/cli-service");
module.exports = defineConfig({
  transpileDependencies: true,
  lintOnSave: false,
  devServer: {
    port: 6103,
    client: {
      webSocketURL: "ws://0.0.0.0:6103/ws",
    },
  },
});

就解决了

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