spread.rs 764 B

123456789101112131415161718192021222324252627282930313233343536
  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 { ..cx.props.attributes, "1: {cx.props.extra_data}\n2: {cx.props.extra_data2}" }
  23. }
  24. }
  25. #[derive(Props)]
  26. struct Props<'a> {
  27. #[props(extends = GlobalAttributes)]
  28. attributes: Vec<Attribute<'a>>,
  29. extra_data: &'a str,
  30. extra_data2: &'a str,
  31. }