taro-router

0.1.1 • Public • Published

此插件旨在使用taro构建微信小程序路由改造,并支持无线层级路由,自定义维护页面栈

使用方式

1、安装npm包

npm install taro-router --save-dev

yarn add taro-router

2、引入包

import router from 'taro-router'

3、下载文件放入项目中

1、在pages目录下创建curtain目录,并将放入index.ts文件

2、将routes.ts文件放入src目录下,并配置路由

最简单使用方式

router.push({name:'home'});

router.replace({name:'home'});

router.switchTab({name:'home'});

router.pop({delta:'home'});

router.relaunch({name:'home'});

参数

name: 路由名称,两种形式1:路由文件中定义的名称 2:从pages开始的包名用英文点隔开,如/pages/goods/detail,可以写成goods.detail。形式2需注意最后一层默认为index,如商品详情转换后为/pages/goods/detail/index

data: 需要传递的参数,json格式(注:switchTab不支持参数,所以无data属性)

success: 跳转成功回调函数

fail: 跳转失败回调函数

complete: 跳转完成回调函数

history: 是否启用页面栈查找跳转,默认不开启,仅限push方法使用

Package Sidebar

Install

npm i taro-router

Weekly Downloads

2

Version

0.1.1

License

MIT

Unpacked Size

11.3 kB

Total Files

9

Last publish

Collaborators

  • axeditor