Ver Fonte

fix: update the sample

j1ngzoue há 3 anos atrás
pai
commit
abbd0b8a39
2 ficheiros alterados com 7 adições e 7 exclusões
  1. 4 4
      docs/guide/src/README.md
  2. 3 3
      notes/README/ZH_CN.md

+ 4 - 4
docs/guide/src/README.md

@@ -5,13 +5,13 @@
 **Dioxus** is a framework and ecosystem for building fast, scalable, and robust user interfaces with the Rust programming language. This guide will help you get started with Dioxus running on the Web, Desktop, Mobile, and more.
 **Dioxus** is a framework and ecosystem for building fast, scalable, and robust user interfaces with the Rust programming language. This guide will help you get started with Dioxus running on the Web, Desktop, Mobile, and more.
 
 
 ```rust
 ```rust
-fn App(cx: Scope) -> Element {
-    let mut count = use_state(&cx, || 0);
+fn app(cx: Scope) -> Element {
+    let (count, set_count) = use_state(&cx, || 0);
 
 
     cx.render(rsx!(
     cx.render(rsx!(
         h1 { "High-Five counter: {count}" }
         h1 { "High-Five counter: {count}" }
-        button { onclick: move |_| count += 1, "Up high!" }
-        button { onclick: move |_| count -= 1, "Down low!" }
+        button { onclick: move |_| set_count(count + 1), "Up high!" }
+        button { onclick: move |_| set_count(count - 1), "Down low!" }
     ))
     ))
 };
 };
 ```
 ```

+ 3 - 3
notes/README/ZH_CN.md

@@ -65,12 +65,12 @@ Dioxus 是一个可移植、高性能的框架,用于在 Rust 中构建跨平
 
 
 ```rust
 ```rust
 fn app(cx: Scope) -> Element {
 fn app(cx: Scope) -> Element {
-    let mut count = use_state(&cx, || 0);
+    let (count, set_count) = use_state(&cx, || 0);
 
 
     cx.render(rsx!(
     cx.render(rsx!(
         h1 { "High-Five counter: {count}" }
         h1 { "High-Five counter: {count}" }
-        button { onclick: move |_| count += 1, "Up high!" }
-        button { onclick: move |_| count -= 1, "Down low!" }
+        button { onclick: move |_| set_count(count + 1), "Up high!" }
+        button { onclick: move |_| set_count(count - 1), "Down low!" }
     ))
     ))
 }
 }
 ```
 ```