Eval binded data in string
-
Hi,
In a
<q-option-group>
component I would like to input a variable into labels. But I don’t know how to achieve that.Here is an example of what I would like to do:
<q-option-group type="radio" v-model="my-v-model" :options="[ {value: '1', label: '{{ user.fullName }} helped me'}, {value: '2', label: '{{ user.fullName }} di not help me'}, ]" />
How to evaluate
{{ user.fullName }}
inside my string ?Thanks for helping
-
<q-option-group type="radio" v-model="my-v-model" :options="[ {value: '1', label: `${user.fullName} helped me`}, {value: '2', label: `${user.fullName} di not help me`}, ]" />
-
Wouaw ! Thanks a lot! I don’t know how I could have found the answer by myself on the internet… I think it should be somewhere in the VueJS’s doc but I did not found…
Best regards
-
This post is deleted! -
One more question related to this topic: what about if I want to put this text in a “config” file ? Because in my “config” file, the “user” variable doesn’t exist.
In my case, I put all the texts in one “plugin” file (/src/plugins/config.js) and if I move the option’s array into the config.js file, I have the error saying that “‘user’ is not defined”.
I don’t know if plugins are the best solution to centralize all the “text” variables of my app ? But if so, how to include variables in my texts ?Thanks