我想获取有关连接到套接字io的数据的信息,并且我根据以下文档在main.js文件中写入了此配置
https://www.npmjs.com/package/vue-socket.io
import VueSocketIO from 'vue-socket.io'
Vue.use(new VueSocketIO({
debug: true,
connection: 'http://es.mappserver.com',
vuex: {
store,
actionPrefix: 'SOCKET_',
mutationPrefix: 'SOCKET_'
},
options: {} //Optional options
}))
new Vue({
sockets: {
connect: function (data) {
console.log('socket connected')
},
customEmit: function (data) {
console.log('this method was fired by the socket server. eg: io.emit("customEmit", data)')
}
},
router,
store,
render: h => h(App),
}).$mount('#app')
这是我组件中的代码片段:
this.$socket.on('currency-channel', (data) => {
console.log(data);
});
我在控制台中收到套接字连接消息,但我什么也没得到,也没有错误 我该如何解决这个问题?我在文档中没有答案