spread.rs 716 B

1234567891011121314151617181920212223242526272829303132333435
  1. use dioxus::prelude::*;
  2. fn main() {
  3. let mut 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. fn spreadable_component(props: Props) -> Element {
  19. rsx! {
  20. audio { ..props.attributes, "1: {props.extra_data}\n2: {props.extra_data2}" }
  21. }
  22. }
  23. #[derive(Props, PartialEq, Clone)]
  24. struct Props {
  25. #[props(extends = GlobalAttributes)]
  26. attributes: Vec<Attribute>,
  27. extra_data: String,
  28. extra_data2: String,
  29. }