Created
January 3, 2022 07:25
-
-
Save VusalGhasanov/b3188ba69839b8ec1c2301cb2cd02faf to your computer and use it in GitHub Desktop.
Vue task
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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