Skip to content

Instantly share code, notes, and snippets.

@jekingohel
Created January 6, 2022 10:06
Show Gist options
  • Save jekingohel/24bf2e2f1ad214d96a01baf460a01e18 to your computer and use it in GitHub Desktop.
Save jekingohel/24bf2e2f1ad214d96a01baf460a01e18 to your computer and use it in GitHub Desktop.
Using Vue component in this gist link. Complete the computed property "activeItems". https://gist.github.com/anish-dcruz/1fa2af7357914750ee2e21f74db4231b
<template>
<div class="widget">
<div v-if="activeItems && activeItems.length > 0">
<ul>
<li v-for="item in activeItems" :key="item.id">
{{item.name}}
</li>
</ul>
</div>
</div>
</template>
<script>
export default {
data() {
return {
loading: true,
list: {
'John': true,
'Jane': true,
'Bob': false
},
}
},
computed: {
activeItems() {
return this.list.filter((x)=> x.active === true);
}
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment