dioxus/examples/spread.rs

37 lines
764 B
Rust
Raw Normal View History

2023-09-27 10:02:49 -05:00
use dioxus::prelude::*;
fn main() {
let mut dom = VirtualDom::new(app);
2023-09-22 09:31:13 -05:00
let _ = dom.rebuild();
let html = dioxus_ssr::render(&dom);
println!("{}", html);
}
fn app(cx: Scope) -> Element {
2023-09-26 19:23:00 -05:00
render! {
Component {
width: "10px",
2023-09-27 10:05:02 -05:00
extra_data: "hello{1}",
extra_data2: "hello{2}",
2023-09-26 19:23:00 -05:00
height: "10px",
2024-01-06 08:58:49 -06:00
left: 1
2023-09-26 19:23:00 -05:00
}
}
}
2023-10-04 08:46:24 -05:00
#[component]
2023-09-22 09:19:54 -05:00
fn Component<'a>(cx: Scope<'a, Props<'a>>) -> Element<'a> {
render! {
2024-01-06 08:58:49 -06:00
audio { ..cx.props.attributes, "1: {cx.props.extra_data}\n2: {cx.props.extra_data2}" }
}
}
2023-09-26 19:23:00 -05:00
#[derive(Props)]
struct Props<'a> {
#[props(extends = GlobalAttributes)]
attributes: Vec<Attribute<'a>>,
2023-09-27 10:05:02 -05:00
extra_data: &'a str,
extra_data2: &'a str,
2023-09-26 19:23:00 -05:00
}