Skip to content

Instantly share code, notes, and snippets.

@qadirpervez
Created May 28, 2022 09:44
Show Gist options
  • Save qadirpervez/b52cb43c0ea1b2bc8416211f1ad01d7b to your computer and use it in GitHub Desktop.
Save qadirpervez/b52cb43c0ea1b2bc8416211f1ad01d7b to your computer and use it in GitHub Desktop.
ObjectKey Map
<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 Object.keys(this.list).map(key => {
return {name: key, active: this.list[key]}
}).filter(singleUser => singleUser.active);
}
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment