Skip to content

Instantly share code, notes, and snippets.

@cdmathukiya
Created January 5, 2022 06:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cdmathukiya/5e6aef436ccd3cfed01e84864c7cdbb6 to your computer and use it in GitHub Desktop.
Save cdmathukiya/5e6aef436ccd3cfed01e84864c7cdbb6 to your computer and use it in GitHub Desktop.
Vue component
<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