mirror of https://github.com/sveltejs/svelte
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
561 B
30 lines
561 B
7 years ago
|
{{#each things as thing}}
|
||
|
<Visibility bind:isVisible="visibilityMap[thing]">
|
||
|
<p>{{thing}} ({{visibilityMap[thing]}})</p>
|
||
|
</Visibility>
|
||
|
{{/each}}
|
||
|
|
||
|
<script>
|
||
|
import Visibility from './Visibility.html';
|
||
|
import counter from './counter.js';
|
||
|
|
||
|
export default {
|
||
|
data() {
|
||
|
return {
|
||
|
things: ['first thing', 'second thing'],
|
||
|
visibilityMap: {}
|
||
|
};
|
||
|
},
|
||
|
|
||
|
computed: {
|
||
|
visibleThings: (things, visibilityMap) => {
|
||
|
counter.count += 1;
|
||
|
return things.filter(text => visibilityMap[text]);
|
||
|
}
|
||
|
},
|
||
|
|
||
|
components: {
|
||
|
Visibility
|
||
|
}
|
||
|
};
|
||
|
</script>
|