Última actividad 1729152954

Dioxus-6.rs Sin formato
1fn Counters() -> impl IntoView {
2 let counters = RwSignal::new(vec![0; 10]);
3
4 view! {
5 <button on:click=move |_| counters.update(|n| n.push(n.len()))>"Add Counter"</button>
6 <For
7 each=move || 0..counters.with(Vec::len)
8 key=|idx| *idx
9 let:idx
10 >
11 <li>
12 <button on:click=move |_| counters.update(|n| n[idx] += 1)>
13 {Memo::new(move |_| counters.with(|n| n[idx]))}
14 </button>
15 <button on:click=move |_| counters.update(|n| { n.remove(idx); })>
16 "Remove"
17 </button>
18 </li>
19 </For>
20 }
21}