dioxus/examples/simple_list.rs

36 lines
880 B
Rust
Raw Normal View History

use dioxus::prelude::*;
fn main() {
dioxus_desktop::launch(app);
}
fn app(cx: Scope) -> Element {
cx.render(rsx!(
2022-11-16 07:22:41 +00:00
div { id: "123123123",
// Use Map directly to lazily pull elements
(0..10).map(|f| rsx! { "{f}" }),
2022-11-16 07:22:41 +00:00
// Collect into an intermediate collection if necessary, and call into_iter
["a", "b", "c", "d", "e", "f"]
2022-11-16 07:22:41 +00:00
.into_iter()
.map(|f| rsx! { "{f}" })
.collect::<Vec<_>>()
.into_iter(),
// Use optionals
Some(rsx! { "Some" }),
2022-11-17 06:18:44 +00:00
// use a for loop or unterminated conditional
div {
for name in 0..10 {
rsx! { "{name}" }
}
if true {
rsx!{ "hello world!" }
}
}
2022-11-16 07:22:41 +00:00
}
))
}