@microprogram/router
v1.0.0-beta.10
Published
[docs](https://jserwang.github.io/microprogram-router/)
Downloads
2
Readme
microprogram-router
Usage
yarn add @microprogram/router
# npm
npm install @microprogram/router
Create router
directory in the project, and create an index.js
or index.ts
file in the router
directory
import {
createRouter,
createWechatHistory,
RouteRecord
} from '@microprogram/router'
const routes: RouteRecord[] = [
{
path: '/',
page: 'pages/index/index'
},
{
path: '/log',
page: 'pages/log/index'
}
]
const router = createRouter({
history: createWechatHistory(),
routes
})
export default router
in app.ts
import router from './router/index'
App({
router
})
in anywhere to use
import { useRoute, useRouter } from '@microprogram/router'
Page({
onShow() {
// 获取当前页面中的参数
useRoute().params
},
handleClick() {
useRouter().push('/log')
}
})
Development
git clone https://github.com/JserWang/microprogram-router
cd microprogram-router
yarn
yarn build