javascript - Vue.js Property or method "options" is not defined on the instance but referenced during render
Solution:
In your v-for
loop, VueJS is trying to find options
key in your data object. Your options are under investmentForm
key, so in your v-for, instead of
v-for="option in options"
You should write
v-for="option in investmentForm.options"
The error you are getting simply means that Vue does not know what options
is as it can't find it anywhere.
Answer
Solution:
options
is inside investmentForm
data so you need to update this
<option v-for="option in investmentForm.options" v-bind:value="option.value">
{{ option.text }}
</option>
Answer
Solution:
options is inside investmentForm, so it must be invoked in the template like this investmentForm.options.
An alternative to the solutions already given would be to add a computed method, this way you don't need to change the template:
// ...
computed: {
options() {
return investmentForm.options;
}
},
// ...
Source