Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
175 views
in Technique[技术] by (71.8m points)

vue.js - How to access a module from a store by having its name as a string?

I'm new in Vuejs and I have a problem.

I need to use a store but I only have its name in string. I know that I can access the method that I wrote (all() ) of the store by writing : storeName.all

but I only have this.storeName as a string and writing this.storeName.all doesn't work


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The store is basically an abject. We can access object properties in these ways:

this.$store.storeName;

or if we know store name in string, we can access like this :

this.$store["storeName"];

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...