data(){
return {
socket:null
}
}
mounted() {
// 初始化
this.init()
},
// 组件被销毁时关闭监听,如不关闭,websocket会一直挂载
beforeDestroy() {
this.close()
},
methods: {
// 进入聊天室,连接socket
init: function () {
let that &
websocket 配置 vue
最新推荐文章于 2024-01-12 11:21:17 发布