Add Router
parent
2342f3e814
commit
ef55737c95
|
@ -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')
|
||||
}
|
||||
]
|
||||
})
|
||||
```
|
Loading…
Reference in New Issue