spread.rs 784 B

1234567891011121314151617181920212223242526272829303132333435363738
  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. fn Component<'a>(cx: Scope<'a, Props<'a>>) -> Element<'a> {
  20. render! {
  21. audio {
  22. ..cx.props.attributes,
  23. "1: {cx.props.extra_data}\n2: {cx.props.extra_data2}"
  24. }
  25. }
  26. }
  27. #[derive(Props)]
  28. struct Props<'a> {
  29. #[props(extends = GlobalAttributes)]
  30. attributes: Vec<Attribute<'a>>,
  31. extra_data: &'a str,
  32. extra_data2: &'a str,
  33. }