我试图在组件的已安装挂钩中获取套接字ID。但是,当我刷新页面时,它可以正常工作,而当用户使用$ router.push()
输入组件时,它将无法正常工作 getSocketId() {
return new Promise((resolve, reject) => {
debugger;
Echo.connector.pusher.connection.bind('connected', function () {
resolve(Echo.socketId())
});
})
},
mounted(){
this.getSocketId().then((socketId => {
let data = {
data : {
booking_id : this.$route.params.id,
user_id : JSON.parse(localStorage.getItem("app_user_data")).id,
is_active: 1
},
socket_id : socketId
}
this.postUserDataToFirebolt(data)
this.addUserInBooking(data)
}))
}