Merge pull request #2058 from Ti-webdev/patch-1

guide: change "Keyed each blocks" example to v3
pull/2063/head
Rich Harris 6 years ago committed by GitHub
commit aac2cb17b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -18,7 +18,7 @@ It's easier to show the effect of this than to describe it. Open the following e
```html
<!-- { title: 'Keyed each blocks' } -->
<button on:click="update()">update</button>
<button on:click="{update}">update</button>
<section>
<h2>Keyed</h2>
@ -46,29 +46,21 @@ It's easier to show the effect of this than to describe it. Open the following e
</style>
<script>
import { slide } from 'svelte-transitions';
var people = ['Alice', 'Barry', 'Cecilia', 'Douglas', 'Eleanor', 'Felix', 'Grace', 'Horatio', 'Isabelle'];
import { slide } from 'svelte/transition';
const names = ['Alice', 'Barry', 'Cecilia', 'Douglas', 'Eleanor', 'Felix', 'Grace', 'Horatio', 'Isabelle'];
function random() {
return people
return names
.filter(() => Math.random() < 0.5)
.map(name => ({ name }))
.map(name => ({ name }));
}
let people = random();
function update() {
people = random();
}
export default {
data() {
return { people: random() };
},
methods: {
update() {
this.set({ people: random() });
}
},
transitions: { slide }
};
</script>
```

Loading…
Cancel
Save