I'm showing a list of release versions, but the part I'm stuck on is I want to be able to click the release version and show the job_execs for that version. I'm not sure how to do this other than using a ternary expression and binding it to click event. Anyway, what I'm trying to do is not working because nothing changes when I click the versions.
<template>
<td>
<div v-for="release in release_versions" :key="release">
<li>
<span @click="showRelease = showRelease === release.version ? '' : release">
Release {{ release.version }}
</span>
<ul v-if="showRelease === release.version">
{{ release.job_execs }}
</ul>
</li>
</div>
</td>
</template>
<script>
export default {
name: 'LatestBuilds',
data() {
return {
release_versions: [
{ version: '1', job_execs: [] },
{ version: '2', job_execs: [] },
],
showRelease: false,
}
},
}
</script>
Important things to note:
job_execsis populated with data, I'm just not showing it in the OP;the numbers of versions and
job_execsare always changing;I'd rather not use a ternary expression if at all possible, just not sure how else to do this.
falsebut you are comparingbooleans, andstrings.@click="changeRelease(release)", pass in the parameter and change that data prop in the method.showRelease = release.versionand then it will work.