webview_web.rs 911 B

12345678910111213141516171819202122232425262728
  1. //! Example: Webview Renderer
  2. //! -------------------------
  3. //!
  4. //! This example shows how to use the dioxus_desktop crate to build a basic desktop application.
  5. //!
  6. //! Under the hood, the dioxus_desktop crate bridges a native Dioxus VirtualDom with a custom prebuilt application running
  7. //! in the webview runtime. Custom handlers are provided for the webview instance to consume patches and emit user events
  8. //! into the native VDom instance.
  9. //!
  10. //! Currently, NodeRefs won't work properly, but all other event functionality will.
  11. use dioxus::prelude::*;
  12. fn main() {
  13. dioxus::desktop::launch(app);
  14. }
  15. fn app(cx: Scope) -> Element {
  16. let mut count = use_state(&cx, || 0);
  17. cx.render(rsx! {
  18. div {
  19. h1 { "Hifive counter: {count}" }
  20. button { onclick: move |_| count += 1, "Up high!" }
  21. button { onclick: move |_| count -= 1, "Down low!" }
  22. }
  23. })
  24. }