出現(xiàn)的錯(cuò)誤情況:
vue創(chuàng)建項(xiàng)目打開頁面后可以運(yùn)行正常,就是控制臺(tái)一直隔幾秒報(bào)websocket的connection錯(cuò)誤
錯(cuò)誤如下:
WebSocket connection to 'ws://localhost:3000/ws' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
WebSocketClient | @ | WebSocketClient.js?5586:16 | |
initSocket | @ | socket.js?d6e0:24 | |
eval | @ | socket.js?d6e0:48 |
?文章來源:http://www.zghlxwxcb.cn/news/detail-537831.html
?解決方法:
?在vue.config.js中進(jìn)行下列的配置文章來源地址http://www.zghlxwxcb.cn/news/detail-537831.html
const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
transpileDependencies: true,
lintOnSave: false, //關(guān)閉語法檢查
devServer:{
host: '0.0.0.0',
port:3000,
client: {
webSocketURL: 'ws://0.0.0.0:3000/ws',
},
headers: {
'Access-Control-Allow-Origin': '*',
}
}
})
到了這里,關(guān)于WebSocket connection to ‘ws://localhost:3000/ws‘ failed: Error in connection establishment: net::ERR的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!