event_javascript.rs 526 B

1234567891011121314151617181920212223242526
  1. ## JavaScript Handlers
  2. Instead of passing a closure, you can also pass a string to event handlers – this lets you use JavaScript (if your renderer can execute JavaScript):
  3. ```rust
  4. {{#include ../../../examples/event_javascript.rs:rsx}}
  5. ```
  6. #![allow(non_snake_case)]
  7. use dioxus::prelude::*;
  8. fn main() {
  9. dioxus::desktop::launch(App);
  10. }
  11. fn App(cx: Scope) -> Element {
  12. cx.render(rsx! {
  13. // ANCHOR: rsx
  14. div {
  15. onclick: "alert('hello world')",
  16. }
  17. // ANCHOR_END: rsx
  18. })
  19. }