1👍
✅
I’d use a computed property that returns an array containing…
- Only
a
/Module1
if it exists - The entire
exampleObject
/checklist.types
otherwise
Then you can just iterate that computed property
export default {
data: () => ({
checklist: {
types: [/* whatever */]
}
}),
computed: {
modules: ({ checklist: { types } }) => {
const module1 = types.find(({ Name }) => Name === "Module1")
return module1 ? [ module1 ] : types
}
}
}
<div v-for="module in modules" :key="module.Name">
<span>{{ module.Name }}</span>
</div>
Source:stackexchange.com