You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/en/essentials/api/index.md
+7-10Lines changed: 7 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,10 +16,9 @@ createApp(<App />, '#app');
16
16
17
17
## setData
18
18
19
-
Modify page data.
19
+
Modifying page data is best performed at the end of the logic.
20
20
21
-
The first parameter is a function, which must be passed. Execute the callback function to modify the associated page data.
22
-
The second parameter is the context, which must be passed in the outer scope and not in the inner scope.
21
+
The first parameter is the context, which is required in the outer scope but not in the inner scope. In the inner scope, it can be referenced directly in the function component.
23
22
24
23
**Internal scope:**
25
24
@@ -28,9 +27,8 @@ function App({ setData }) {
28
27
let count =0;
29
28
30
29
functionadd() {
31
-
setData(() => {
32
-
count++;
33
-
});
30
+
count++;
31
+
setData();
34
32
}
35
33
36
34
return () => (
@@ -50,9 +48,8 @@ import { setData } from 'mettle';
50
48
let count =0;
51
49
52
50
functionadd() {
53
-
setData(() => {
54
-
count++;
55
-
}, App);
51
+
count++;
52
+
setData(App);
56
53
}
57
54
58
55
functionApp() {
@@ -65,7 +62,7 @@ function App() {
65
62
}
66
63
```
67
64
68
-
The third parameter is optional. Its type is `Symbol` and is used with the built-in attribute`$memo` to indicate updated data.
65
+
The second parameter is optional and is of type `Symbol`. It is used with the built-in property`$memo` to indicate updated data.
0 commit comments