javascript - Can the Vuex instance name only be store?
迷茫
迷茫 2017-07-05 11:08:19
0
2
915

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?

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

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

But this is superfluous

Ty80

Refer to this official example:

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

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!