After using socket.io in vue, how to change the value in store after sockets gets the background data?

after the following settings, you can connect to the local server

import store from "./store"
import VueSocketio from "vue-socket.io";
import socketio from "socket.io-client";
Vue.use(VueSocketio, socketio("http://127.0.0.1:7777/"),store);

the next step is to get the background data and assign values

sockets: {
    getData: (data) => {
      console.log(this.$store); 
    }
}   

print out undefined. Try printing this in mounted using store
normally elsewhere. This is VueComponent {_ uid: 4, _ isVue: true, $options: {. }, _ renderProxy: Proxy, _ self: VueComponent,. }
print this in sockets is {a: { }}
a: {name: "Home", components: { }, sockets: {. }, mounted: premises, methods: {. }, which is the information for the current page.
what should I do


this.$store is the store object that Vuex automatically injects into each subcomponent of the instance for convenience. In fact, it is the store exposed in your store.js .
call in non-vue instance components can be directly introduced

import store from './store'

export default {
  sockets: {
    getData: (data) => {
      //store.state...
      //store.commit('')
      console.log(store);
    }
  }
}
Menu