Answer the question
In order to leave comments, you need to log in
How to properly specify nested v-ifs?
There is a component structure like this
...
<div class="role-grid">
<div class="role-my">
<h5><strong>Me:</strong></h5>
<ul class="dots">
<template v-for="(m, index) in cd.role" :key="index">
<li v-for="m in m.me">{{ m.li }}</li>
</template>
</ul>
</div>
<div class="role-others">
<h5><strong>Others:</strong></h5>
<ul class="dots">
<template v-for="(o, index) in cd.role" :key="index">
<li v-for="o in o.other">{{ o.li }}</li>
</template>
</ul>
</div>
</div>
....
"role": [
{
"me": [
{
"li": "Lorem"
},
{
"li": "Lorem"
},
{
"li": "Lorem"
},
{
"li": "Lorem"
}
],
"other": [
{
"li": "Lorem"
},
{
"li": "Lorem"
}
]
}
],
<div class="role-others">
<h5><strong>Others:</strong></h5>
<ul class="dots">
<template v-for="(o, index) in cd.role" :key="index">
<li v-for="o in o.other">{{ o.li }}</li>
</template>
</ul>
</div>
"other": [
{
"li": ""
},
{
"li": ""
}
]
Answer the question
In order to leave comments, you need to log in
<div class="role-others" v-if="cd.role.some(el => el.other.length)">
<h5><strong>Others:</strong></h5>
<ul class="dots">
<template v-for="(o, index) in cd.role" :key="index">
<li v-for="o in o.other">{{ o.li }}</li>
</template>
</ul>
</div>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question