Merge branch 'DioxusLabs:master' into lazy_tui
This commit is contained in:
34 files changed
+212
-92
No files matched your search
@@ -42,6 +42,7 @@ These examples are not necessarily meant to be run, but rather serve as a refere
|
||||
| [Complete rsx reference](./rsx_usage.rs) | A complete reference for all rsx! usage | ✅ |
|
||||
| [Event Listeners](./listener.rs) | Attach closures to events on elements | ✅ |
|
||||
| [Inline Props](./inlineprops.rs) | Using the `#[inline_props]` macro | ✅ |
|
||||
| [Eval](./eval.rs) | Evaluate dynamic JavaScript code | ✅ |
|
||||
|
||||
|
||||
## Show me some examples!
|
||||
|
||||
@@ -36,7 +36,7 @@ pub fn NonUpdatingEvents(cx: Scope) -> Element {
|
||||
cx.render(rsx! {
|
||||
div {
|
||||
button {
|
||||
onclick: move |_| log::info!("Did not cause any updates!"),
|
||||
onclick: move |_| log::trace!("Did not cause any updates!"),
|
||||
"Click me to log!"
|
||||
}
|
||||
}
|
||||
@@ -46,9 +46,9 @@ pub fn NonUpdatingEvents(cx: Scope) -> Element {
|
||||
pub fn DisablePropagation(cx: Scope) -> Element {
|
||||
cx.render(rsx! {
|
||||
div {
|
||||
onclick: move |_| log::info!("event propagated to the div!")
|
||||
onclick: move |_| log::trace!("event propagated to the div!")
|
||||
button {
|
||||
onclick: move |evt| log::info!("Button will allow propagation"),
|
||||
onclick: move |evt| log::trace!("Button will allow propagation"),
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
use dioxus::prelude::*;
|
||||
|
||||
fn main() {
|
||||
dioxus::desktop::launch(app);
|
||||
}
|
||||
|
||||
fn app(cx: Scope) -> Element {
|
||||
let script = use_state(&cx, String::new);
|
||||
let eval = use_eval(&cx);
|
||||
|
||||
cx.render(rsx! {
|
||||
div {
|
||||
input {
|
||||
placeholder: "Enter an expression",
|
||||
value: "{script}",
|
||||
oninput: move |e| script.set(e.value.clone()),
|
||||
}
|
||||
button {
|
||||
onclick: move |_| eval(script),
|
||||
|
||||
"Execute"
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user