dioxus/examples/spread.rs

36 lines
716 B
Rust
Raw Normal View History

use dioxus::prelude::*;
fn main() {
let mut dom = VirtualDom::prebuilt(app);
let html = dioxus_ssr::render(&dom);
println!("{}", html);
}
fn app() -> Element {
2024-01-16 13:18:46 -06:00
rsx! {
2024-01-16 11:04:37 -06:00
spreadable_component {
2023-09-26 19:23:00 -05:00
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
}
}
}
2024-01-16 11:04:37 -06:00
fn spreadable_component(props: Props) -> Element {
2024-01-16 13:18:46 -06:00
rsx! {
2024-01-14 15:21:19 -06:00
audio { ..props.attributes, "1: {props.extra_data}\n2: {props.extra_data2}" }
}
}
2023-09-26 19:23:00 -05:00
2024-01-14 15:21:19 -06:00
#[derive(Props, PartialEq, Clone)]
struct Props {
2023-09-26 19:23:00 -05:00
#[props(extends = GlobalAttributes)]
2024-01-14 15:21:19 -06:00
attributes: Vec<Attribute>,
2024-01-14 15:21:19 -06:00
extra_data: String,
extra_data2: String,
2023-09-26 19:23:00 -05:00
}