0👍
The right solution would be to
- Create a vue.use for the connection with autoConnect: false below import VueSocketCluster from ‘vue-socket-cluster’
> Vue.use(VueSocketCluster, { > connections: [{ > name: 'SeoScan', // Each connection object must have a name and the name must be unique in the array > hostname: 'localhost', > secure: false, > port: 5128, > rejectUnauthorized: false, > autoConnect: false > }] > });
-
then, add in your components (here HelloWorld.vue) the event listeners under export default
SeoScanEvents: {
connect: function (data) {
console.log(‘socket connected’)
console.log(data)
},
random (data) {
console.log(data)
}
} -
In the method submit1 rather than calling the method connect from the root, call the method that will start the connection: this.$SeoScanClient.connect();
- [Vuejs]-MVC form submission need query string with %20 not with '+'
- [Vuejs]-Vue-Router not loading component
Source:stackexchange.com