mirror of https://github.com/sveltejs/svelte
parent
6c8bd6e5aa
commit
4be902b930
@ -1,23 +1,23 @@
|
|||||||
<script>
|
<script>
|
||||||
import Thing from './Thing.svelte';
|
import Thing from './Thing.svelte';
|
||||||
|
|
||||||
let things = [
|
let array = [
|
||||||
{ id: 1, color: '#0d0887' },
|
{ id: 1, data: 1 },
|
||||||
{ id: 2, color: '#6a00a8' },
|
{ id: 2, data: 2 },
|
||||||
{ id: 3, color: '#b12a90' },
|
{ id: 3, data: 3 },
|
||||||
{ id: 4, color: '#e16462' },
|
{ id: 4, data: 4 },
|
||||||
{ id: 5, color: '#fca636' }
|
{ id: 5, data: 5 }
|
||||||
];
|
];
|
||||||
|
|
||||||
function handleClick() {
|
function handleClick() {
|
||||||
things = things.slice(1);
|
array = array.slice(1);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<button on:click={handleClick}>
|
<button on:click={handleClick}>
|
||||||
Remove first thing
|
Remove first element
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
{#each things as thing}
|
{#each array as element}
|
||||||
<Thing current={thing.color}/>
|
<Thing current={element.data}/>
|
||||||
{/each}
|
{/each}
|
@ -1,23 +1,23 @@
|
|||||||
<script>
|
<script>
|
||||||
import Thing from './Thing.svelte';
|
import Thing from './Thing.svelte';
|
||||||
|
|
||||||
let things = [
|
let array = [
|
||||||
{ id: 1, color: '#0d0887' },
|
{ id: 1, data: 1 },
|
||||||
{ id: 2, color: '#6a00a8' },
|
{ id: 2, data: 2 },
|
||||||
{ id: 3, color: '#b12a90' },
|
{ id: 3, data: 3 },
|
||||||
{ id: 4, color: '#e16462' },
|
{ id: 4, data: 4 },
|
||||||
{ id: 5, color: '#fca636' }
|
{ id: 5, data: 5 }
|
||||||
];
|
];
|
||||||
|
|
||||||
function handleClick() {
|
function handleClick() {
|
||||||
things = things.slice(1);
|
array = array.slice(1);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<button on:click={handleClick}>
|
<button on:click={handleClick}>
|
||||||
Remove first thing
|
Remove first element
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
{#each things as thing (thing.id)}
|
{#each array as element (element.id)}
|
||||||
<Thing current={thing.color}/>
|
<Thing current={element.data}/>
|
||||||
{/each}
|
{/each}
|
Loading…
Reference in new issue