Add Router

master
yutent 2023-09-25 15:55:58 +08:00
parent 2342f3e814
commit ef55737c95
1 changed files with 24 additions and 0 deletions

24
Router.md Normal file

@ -0,0 +1,24 @@
# 路由
> 仿`vue-router`的API,实现一套简化版的路由模块。可支持传统的`hash`路由, 以及新的`history`路由。
>> **注意:** 由于`web components`的限制, 不支持嵌套路由。
```js
import { createRouter, createWebHistory } from 'wkitd'
const router = createRouter({
history: createWebHistory(), // 默认createWebHashHistory
routes: [
{
path: '/',
name: 'wc-home' // 必须为页面组件的标签名
},
{
path: '/about',
name: 'wc-about',
component: () => import('./views/about.js')
}
]
})
```