Skip to content

Instantly share code, notes, and snippets.

@VusalGhasanov
Created January 3, 2022 07:25
Show Gist options
  • Save VusalGhasanov/b3188ba69839b8ec1c2301cb2cd02faf to your computer and use it in GitHub Desktop.
Save VusalGhasanov/b3188ba69839b8ec1c2301cb2cd02faf to your computer and use it in GitHub Desktop.
Vue task
<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() {
let activeItems = []
Object.entries(obj).forEach(([value, key]) => {
if(key === true){
activeElements.push({name : value, active: key});
}
})
return activeItems;
}
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment