-
Notifications
You must be signed in to change notification settings - Fork 0
/
Array.vue
46 lines (46 loc) · 982 Bytes
/
Array.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<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 `this.list` as an Array of object and filter by if active is true
Expected output
[
{name: 'John', active: true},
{name: 'Jane', active: true}
]
*/
var result = [];
for(const [key, value] of Object.entries(this.list))
{
if(value == true)
{
result.push({'name' : key, 'active' : value});
}
}
return result;
}
}
}
</script>