problem description
vue websocket is encapsulated, and the component rendering completes sending data, which is faster than the websocket connection. How to solve it?
the environmental background of the problems and what methods you have tried
websocket,websocket.js.
created
websocket
related codes
/ / Please paste the code text below (do not replace the code with pictures)
parent component
created(){
setInterval(() => {
this.socketApi.registeSendSock(2)
}, 8000)
}
subcomponents
mounted(){
this.$nextTick(() => {
var type = 5
var sendData = new Object
sendData.controlType = 11
console.log(sendData)
this.socketApi.controlsendSock(type,sendData)
})
},
what result do you expect? What is the error message actually seen?
how to send data after the connection is completed