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/changeLog/index.md
+5-1Lines changed: 5 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,10 @@
1
1
# Change Log
2
2
3
-
## v1.7.0 (Latest)
3
+
## v1.7.1 (Latest)
4
+
5
+
- Enhanced integration with [mettleRouter](/tool/mettleRouter/).
6
+
7
+
## v1.7.0
4
8
5
9
- Introducing the `Signals` mechanism, which automatically updates components and the UI when state changes, ensuring the most efficient operation possible.
Copy file name to clipboardExpand all lines: doc/en/essentials/api/index.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -232,6 +232,10 @@ function App() {
232
232
}
233
233
```
234
234
235
+
## resetView
236
+
237
+
Integrate [mettleRouter](/tool/mettleRouter/) to reset the current routing view.
238
+
235
239
## html
236
240
237
241
` html`` ` is a tag function. The syntax for a tag function is to directly follow the function name with a template string. For example, you can write HTML tags directly in the template string.
Copy file name to clipboardExpand all lines: doc/en/tool/mettleRouter/index.md
+55-1Lines changed: 55 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,6 +20,8 @@ The first parameter is an array object, which is the routing component to be reg
20
20
21
21
The second parameter needs to be passed to the `resetView` API, and the page matching the corresponding path will be updated accordingly.
22
22
23
+
The first two parameters must be passed, and the third parameter is optional and is used to configure the selector of the root node of the routing page.
24
+
23
25
```js
24
26
// router/index.js
25
27
import { resetView } from'mettle';
@@ -39,7 +41,8 @@ const router = initRouter(
39
41
template: About,
40
42
},
41
43
],
42
-
resetView
44
+
resetView,
45
+
'#router',
43
46
);
44
47
45
48
exportdefaultrouter;
@@ -59,6 +62,23 @@ function App() {
59
62
createApp(<App />, '#app');
60
63
```
61
64
65
+
If you configure the third parameter, the `<Router>` component must set a parent node.
66
+
67
+
```jsx
68
+
// main.jsx
69
+
import { createApp } from'mettle';
70
+
importRouterfrom'./router/index';
71
+
72
+
functionApp() {
73
+
return (
74
+
<div id='router'>
75
+
<Router></Router>
76
+
</div>
77
+
);
78
+
}
79
+
createApp(<App />, '#app');
80
+
```
81
+
62
82
### linkTo()
63
83
64
84
If you need to jump to the corresponding page, use the `linkTo()` method, you can pass the corresponding path and parameters to be passed, or you can directly pass the path string.
@@ -90,6 +110,40 @@ function About() {
90
110
91
111
If you perform a route parameter operation, you need to obtain the parameter object. You can directly execute the `toParse()` method to obtain the object information.
92
112
113
+
```jsx
114
+
console.log(toParse());
115
+
```
116
+
117
+
### hashChange
118
+
119
+
When the route changes, the `hashChange` event is triggered. You can listen to this event and perform custom actions.
120
+
121
+
```jsx
122
+
import { hashChange } from'mettle-router';
123
+
124
+
hashChange(() => {
125
+
if (location.hash==='#/login') {
126
+
isLogin.value=true;
127
+
} else {
128
+
isLogin.value=false;
129
+
}
130
+
});
131
+
```
132
+
133
+
Returns the function to cancel listening.
134
+
135
+
```jsx
136
+
constremoveListener=hashchange(() => {
137
+
console.log('Hash变化:', location.hash);
138
+
});
139
+
140
+
// removeListener();
141
+
```
142
+
93
143
### routerVersion
94
144
95
145
You can get the version information of `mettleRouter`.
0 commit comments