0.1.5 • Published 5 years ago

@tancc/router v0.1.5

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

這是一個非常小而且基礎的 router 套件,扣掉型別定義整體不到 100 行 (目前只是造輪子玩一下而已,不一定會繼續更新呵呵)

安裝

yarn

使用

import { Router, createBrowserHistory } from 't-router'

// 1. 定義 route。支援動態載入
const routes = [
  {
    path: '/',
    component: Home
  },
  {
    path: '/home/:userId',
    getComponent: () => import('./User').then(module => module.default)
  }
]

// 2. 定義 history
const h = createBrowserHistory()

// 3. 回傳 Router component
const App = () => <Router routes={routes} history={h} />

開發

  1. yarn bundle && cd ./example && yarn
  2. yarn start
0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago