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 ```html
<!-- { title: 'Keyed each blocks' } --> <!-- { title: 'Keyed each blocks' } -->
<button on:click="update()">update</button> <button on:click="{update}">update</button>
<section> <section>
<h2>Keyed</h2> <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> </style>
<script> <script>
import { slide } from 'svelte-transitions'; import { slide } from 'svelte/transition';
var people = ['Alice', 'Barry', 'Cecilia', 'Douglas', 'Eleanor', 'Felix', 'Grace', 'Horatio', 'Isabelle'];
const names = ['Alice', 'Barry', 'Cecilia', 'Douglas', 'Eleanor', 'Felix', 'Grace', 'Horatio', 'Isabelle'];
function random() { function random() {
return people return names
.filter(() => Math.random() < 0.5) .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> </script>
``` ```

Loading…
Cancel
Save