mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
36 lines
646 B
Plaintext
36 lines
646 B
Plaintext
class {
|
|
onCreate() {
|
|
this.callCount = 0;
|
|
this.state = {
|
|
list: [{
|
|
id: "foo",
|
|
text: "Foo Text"
|
|
}, {
|
|
id: "bar",
|
|
text: "Bar Text"
|
|
}]
|
|
}
|
|
}
|
|
|
|
calcKey(id) {
|
|
this.callCount++;
|
|
return `${id}`;
|
|
}
|
|
|
|
swap() {
|
|
const [a, b] = this.state.list;
|
|
this.state.list = [b, a];
|
|
}
|
|
}
|
|
|
|
<div.root>
|
|
<for|item| of=state.list>
|
|
<div key=component.calcKey(item.id)>
|
|
${item.text}
|
|
</div>
|
|
<div>
|
|
Non Keyed ${item.text}
|
|
</div>
|
|
</for>
|
|
</div>
|