I want to add a variable to my code, so it calls different functions when I need it but it doesn't work because of the string's quotes. What type should I use or how to strip those quotes from the string?
Asked
Active
Viewed 66 times
-2
-
3Please don't upload [images of code](https://meta.stackoverflow.com/a/285557/3082296). They can't be copied to reproduce the issue, they aren't searchable for future readers and they are harder to read than text. Please post the actual code **as text** to create a [mcve]. – adiga Nov 19 '20 at 09:29
-
Also, what is the actual property you want to access? – adiga Nov 19 '20 at 09:29
-
Your question should be *how to access vuex getters dynamically based on data property* – Boussadjra Brahim Nov 19 '20 at 09:33
1 Answers
1
You could use brackets accessor :
rawData(){
return this.$store.getters['get'+this.dataName]
}
rawData
should be a computed property and 'get'+this.dataName
has to be in your getters like getTodos

Boussadjra Brahim
- 82,684
- 19
- 144
- 164