5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-18 18:09:30 +08:00
wails/website/i18n/zh-Hans/docusaurus-plugin-content-docs/version-v2.8.0/guides/routing.mdx
Lea Anthony 772f870eb3
v2.8.0
2024-02-08 21:28:28 +11:00

48 lines
1.1 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 路由
路由是一种在应用程序中切换视图的流行方式。 此页面提供了有关如何执行此操作的一些指导。
## 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/en/main/router-components/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
);
```