mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-18 09:59:31 +08:00
48 lines
1.1 KiB
Plaintext
48 lines
1.1 KiB
Plaintext
# 路由
|
||
|
||
路由是一种在应用程序中切换视图的流行方式。 此页面提供了有关如何执行此操作的一些指导。
|
||
|
||
## Vue
|
||
|
||
在 Vue 中推荐的路由方法是 [Hash 模式](https://next.router.vuejs.org/guide/essentials/history-mode.html#hash-mode):
|
||
|
||
```js
|
||
import { createRouter, createWebHashHistory } from "vue-router";
|
||
|
||
const router = createRouter({
|
||
history: createWebHashHistory(),
|
||
routes: [
|
||
//...
|
||
],
|
||
});
|
||
```
|
||
|
||
## Angular
|
||
|
||
在 Angular 中推荐的路由方法是 [HashLocationStrategy](https://codecraft.tv/courses/angular/routing/routing-strategies/#_hashlocationstrategy):
|
||
|
||
```ts
|
||
RouterModule.forRoot(routes, { useHash: true });
|
||
```
|
||
|
||
## React
|
||
|
||
React 中推荐的路由方法是 [HashRouter](https://reactrouter.com/docs/en/v6/routers/hash-router):
|
||
|
||
```jsx
|
||
import { HashRouter } from "react-router-dom";
|
||
|
||
ReactDOM.render(
|
||
<HashRouter basename={"/"}>
|
||
{/* The rest of your app goes here */}
|
||
<Routes>
|
||
<Route path="/" element={<Page0 />} exact />
|
||
<Route path="/page1" element={<Page1 />} />
|
||
<Route path="/page2" element={<Page2 />} />
|
||
{/* more... */}
|
||
</Routes>
|
||
</HashRouter>,
|
||
root
|
||
);
|
||
```
|