mirror of https://github.com/sveltejs/svelte
29 lines
613 B
29 lines
613 B
<ul>
|
|
{{#each items as item}}
|
|
{{#if filter(item, currentFilter)}}
|
|
<li>{{item.description}}</li>
|
|
{{/if}}
|
|
{{/each}}
|
|
</ul>
|
|
|
|
<script>
|
|
export default {
|
|
data: () => ({
|
|
currentFilter: 'completed',
|
|
items: [
|
|
{ description: 'one', completed: false },
|
|
{ description: 'two', completed: false },
|
|
{ description: 'three', completed: false }
|
|
]
|
|
}),
|
|
|
|
helpers: {
|
|
filter ( item, currentFilter ) {
|
|
if ( currentFilter === 'all' ) return true;
|
|
if ( currentFilter === 'completed' ) return item.completed;
|
|
if ( currentFilter === 'active' ) return !item.completed;
|
|
}
|
|
}
|
|
};
|
|
</script>
|