Код IT
← Каталог

Экосистема приложений на Rust — Dioxus

Фрагмент из «Экосистема приложений на Rust»: Dioxus.

Rust main.rs
use dioxus::prelude::*;

fn app(cx: Scope) -> Element {
    let mut count = use_state(cx, || 0);

    cx.render(rsx! {
        div {
            h1 { "Счётчик: {count}" }
            button { onclick: move |_| count += 1, "+" }
            button { onclick: move |_| count -= 1, "-" }
        }
    })
}

fn main() {
    dioxus::desktop::launch(app);
}
use dioxus::prelude::*;

fn app(cx: Scope) -> Element {
    let mut count = use_state(cx, || 0);

    cx.render(rsx! {
        div {
            h1 { "Счётчик: {count}" }
            button { onclick: move |_| count += 1, "+" }
            button { onclick: move |_| count -= 1, "-" }
        }
    })
}

fn main() {
    dioxus::desktop::launch(app);
}