webview.rs 962 B

12345678910111213141516171819202122232425262728293031
  1. //! Example: Webview Renderer
  2. //! -------------------------
  3. //!
  4. //! This example shows how to use the dioxus_webview crate to build a basic desktop application.
  5. //!
  6. //! Under the hood, the dioxus_webview crate bridges a native Dioxus VirtualDom with a custom prebuit 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, |c| c);
  14. }
  15. static App: FC<()> = |cx| {
  16. let (count, set_count) = use_state_classic(cx, || 0);
  17. cx.render(rsx! {
  18. div {
  19. h1 { "Dioxus Desktop Demo" }
  20. p { "Count is {count}" }
  21. button {
  22. "Click to increment"
  23. onclick: move |_| set_count(count + 1)
  24. }
  25. }
  26. })
  27. };