spread.rs 713 B

123456789101112131415161718192021222324252627282930313233343536
  1. use dioxus::prelude::*;
  2. fn main() {
  3. let dom = VirtualDom::prebuilt(app);
  4. let html = dioxus_ssr::render(&dom);
  5. println!("{}", html);
  6. }
  7. fn app() -> Element {
  8. rsx! {
  9. spreadable_component {
  10. width: "10px",
  11. extra_data: "hello{1}",
  12. extra_data2: "hello{2}",
  13. height: "10px",
  14. left: 1
  15. }
  16. }
  17. }
  18. #[derive(Props, PartialEq, Clone)]
  19. struct Props {
  20. #[props(extends = GlobalAttributes)]
  21. attributes: Vec<Attribute>,
  22. extra_data: String,
  23. extra_data2: String,
  24. }
  25. fn spreadable_component(props: Props) -> Element {
  26. rsx! {
  27. audio { ..props.attributes, "1: {props.extra_data}\n2: {props.extra_data2}" }
  28. }
  29. }