I have an array of categories that is loaded once in the created hook and remains static thereafter. I am rendering these values in a component template.
<template>
<ul>
<li v-for="item in myArray">{{ item }}</li>
</ul>
</template>
My data property does not include myArray as I do not want reactive binding:
data() {
return {
someReactiveData: [1, 2, 3]
};
}
In my create hook:
created() {
// ...
this.myArray = ["value 1", "value 2"];
// ...
}
The issue arises when Vue throws an error stating that I cannot use myArray in the template because it is not available when the DOM is mounted.
So how can I achieve this? And where should component constants be stored?