Created
January 5, 2022 06:02
-
-
Save cdmathukiya/5e6aef436ccd3cfed01e84864c7cdbb6 to your computer and use it in GitHub Desktop.
Vue component
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 :key="item.id" v-for="item in activeItems"> | |
{{item.name}} | |
</li> | |
</ul> | |
</div> | |
</div> | |
</template> | |
<script> | |
export default { | |
data() { | |
return { | |
loading: true, | |
list: { | |
'John': true, | |
'Jane': true, | |
'Bob': false | |
}, | |
} | |
}, | |
computed: { | |
activeItems() { | |
var result = []; | |
var list = this.list | |
var keys = Object.keys(list); | |
for(let i = 0;i <= keys.length; i++ ) { | |
if (list[keys[i]] == true) { | |
let newItem = {name:keys[i], active:true}; | |
result.push(newItem); | |
} | |
} | |
return result | |
} | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment