spread.rs 797 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. use dioxus::prelude::*;
  2. fn main() {
  3. let mut dom = VirtualDom::new(app);
  4. let _ = dom.rebuild();
  5. let html = dioxus_ssr::render(&dom);
  6. println!("{}", html);
  7. }
  8. fn app(cx: Scope) -> Element {
  9. render! {
  10. Component {
  11. width: "10px",
  12. extra_data: "hello{1}",
  13. extra_data2: "hello{2}",
  14. height: "10px",
  15. left: 1,
  16. }
  17. }
  18. }
  19. #[component]
  20. fn Component<'a>(cx: Scope<'a, Props<'a>>) -> Element<'a> {
  21. render! {
  22. audio {
  23. ..cx.props.attributes,
  24. "1: {cx.props.extra_data}\n2: {cx.props.extra_data2}"
  25. }
  26. }
  27. }
  28. #[derive(Props)]
  29. struct Props<'a> {
  30. #[props(extends = GlobalAttributes)]
  31. attributes: Vec<Attribute<'a>>,
  32. extra_data: &'a str,
  33. extra_data2: &'a str,
  34. }