mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-26 22:20:19 +00:00
add a desktop eval example
This commit is contained in:
parent
40869b36ad
commit
5e475fadd9
1 changed files with 25 additions and 0 deletions
25
examples/eval.rs
Normal file
25
examples/eval.rs
Normal file
|
@ -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"
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
Loading…
Reference in a new issue