Home  >  Q&A  >  body text

javascript - Can the Vuex instance name only be store?

Why const variable name = new Vuex.Store({});
You cannot get the defined data by using this.$ variable name, but what if the variable name is store?

迷茫迷茫2662 days ago926

reply all(2)I'll reply

  • 欧阳克

    欧阳克2017-07-05 11:10:19

    const a = new Vuex.Store({})
    Object.defineProperty(Vue.prototype, '$a', {value: this.$store})

    But this is superfluous

    reply
    0
  • PHP中文网

    PHP中文网2017-07-05 11:10:19

    Refer to this official example:

    https://jsfiddle.net/n9jmu5v7...

    In fact, if you change store to another name, it will have no effect.

    reply
    0
  • Cancelreply