I'm trying to display a very simple array in the template. I can't get my head around why this does not work.
I get the data with a try/catch statement. The data is JSON and it has an array inside, so I guess that clarifies as multilevel array.
The constant displays correctly in console.log
, but not in the template.
Trying to display the data
<template>
<!-- This doesn't return anything -->
{{modules}}
<!-- Neither does this -->
<span v-for="(item, index) in modules" :key="index">{{item}}</a>
<!-- This works as it should -->
<li v-for="company in companies" :key="companies.company_name">
{{ company.company_name }}
{{ company.app_modules }}
<pre>{{ company }}</pre>
</li>
</template>
Get the data
const companies = ref([])
try {
// Await and get the data
companies.value = data
const modules = data[0].app_modules
// This logs the array
console.log(modules)
} catch (e) {
console.error(e)
}
The "modules" Array is this simple
[
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9"
]