webview.rs 1.0 KB

1234567891011121314151617181920212223242526272829303132
  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. use dioxus::prelude::*;
  10. fn main() {
  11. let app = dioxus_webview::new(|ctx| {
  12. let (count, set_count) = use_state(ctx, || 0);
  13. html! {
  14. <div>
  15. <h1> "Dioxus Desktop Demo" </h1>
  16. <p> "Count is {count}"</p>
  17. <p> "Count is {count}"</p>
  18. <p> "Data is {data}"</p>
  19. <button onclick=|_| set_count(count + 1) >
  20. "Click to increment"
  21. </button>
  22. </div>
  23. }
  24. });
  25. let f = 10_i32;
  26. println!("hello {}", f);
  27. app.launch(());
  28. }