All Projects → lblblong → tarojs-router-next

lblblong / tarojs-router-next

Licence: MIT License
Taro 小程序路由库/自动生成带参数类型提示的路由方法/允许传递任意类型、任意大小的参数数据/同步的路由方法调用/koa体验一致的路由中间件

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to tarojs-router-next

classmate-map
🧭 一款设计精美、体验优良的地图信息展示小程序,一个更有意思的同学录,可以在小程序中查看班级同学的毕业去向以及地域分布,多联(蹭)系(饭)。
Stars: ✭ 79 (-52.41%)
Mutual labels:  taro
framework
Lite & fast micro PHP framework that is **easy to learn**.
Stars: ✭ 110 (-33.73%)
Mutual labels:  router
taro-best-practices
使用 Taro 开发微信小程序、编译 H5 + React Native 的最佳实践
Stars: ✭ 118 (-28.92%)
Mutual labels:  taro
STCRouter
基于标准URL的iOS路由系统,可实现业务模块组件化,控制器之间零耦合,可实现黑白名单控制,可进行native降级到hybrid。
Stars: ✭ 19 (-88.55%)
Mutual labels:  router
CRRouter
A simple and powerful router
Stars: ✭ 54 (-67.47%)
Mutual labels:  router
UserDeviceTracker
快速定位一个IP或MAC在你的网络中的位置,是网络工程师提高工作效率的利器,也可以为CMDB提供基础网络数据。
Stars: ✭ 36 (-78.31%)
Mutual labels:  router
Computer-Networks
GBN and SR simulation, Distance Vector Algorithm Simulation
Stars: ✭ 21 (-87.35%)
Mutual labels:  router
OpenBSDFirewall
Simple OpenBSD Home Firewall Config for ALIX Board
Stars: ✭ 41 (-75.3%)
Mutual labels:  router
YAWAC
Yet Another Wifi Auto Connect (YAWAC) is a shell script to connect to a dataset of wireless connection and free hotspot like FreeWifi. It's works on OpenWrt.
Stars: ✭ 22 (-86.75%)
Mutual labels:  router
amber-router
A URL Routing shard.
Stars: ✭ 16 (-90.36%)
Mutual labels:  router
router
Bidirectional Ring router. REST oriented. Rails inspired.
Stars: ✭ 78 (-53.01%)
Mutual labels:  router
bs-director
[UNMAINTAINED] BuckleScript bindings to the Director router
Stars: ✭ 22 (-86.75%)
Mutual labels:  router
ultra-router
Router for component-based web apps. Pair with React or <BYOF />.
Stars: ✭ 35 (-78.92%)
Mutual labels:  router
ampersand-router
Clientside router with fallbacks for browsers that don't support pushState. Mostly lifted from Backbone.js.
Stars: ✭ 69 (-58.43%)
Mutual labels:  router
retil
The React Utility Library
Stars: ✭ 46 (-72.29%)
Mutual labels:  router
ruuter
A zero-dependency HTTP router
Stars: ✭ 57 (-65.66%)
Mutual labels:  router
gangxiaoer-taro
博雅塔小程序,基于Taro的版本,同步发布百度小程序,支付宝小程序。
Stars: ✭ 16 (-90.36%)
Mutual labels:  taro
Router
The Hoa\Router library.
Stars: ✭ 29 (-82.53%)
Mutual labels:  router
shim
HTTP Handler shim for Go projects running on AWS Lambda
Stars: ✭ 64 (-61.45%)
Mutual labels:  router
Taro-ParserRichText
适用于 Taro 的小程序富文本组件
Stars: ✭ 32 (-80.72%)
Mutual labels:  taro

tarojs-router-next

它是一个小巧的 Taro(小程序) 路由库,为你提供以下特性:

  • 自动生成带参数类型提示的路由方法
  • 允许传递任意类型、任意大小的参数数据
  • 同步的路由方法调用
  • koa 体验一致的路由中间件

快速开始

使用文档API 文档

Demo(代码)Demo(微信开发者工具打开)

安装核心依赖

$ npm install --save tarojs-router-next

安装路由方法自动生成插件

$ npm install --dev tarojs-router-next-plugin

编译配置(/config/index.js) 的 plugins 字段中引入插件:

const config = {
  plugins: ['tarojs-router-next-plugin'],
}

解决什么问题

  1. 路由跳转的页面 url 没有类型提示容易输错
  2. 路由传参需要手动拼接参数、无法携带任意类型、任意大小的数据
  3. 路由方法是异步的,页面通过 EventChannel 通信,事件的回调方法可读性差、耦合度高、只能在回调内部处理异常
  4. 路由跳转的鉴权等实现起来比较麻烦

如何解决

1. 路由跳转的页面 url 没有类型提示容易输错

tarojs-router-next 不需要使用者手写页面 url,它会监听项目 src/pages 内容变化,自动为使用者生成对应的路由方法并附加到 Router 类上,比如以下列子:

左边的页面结构会生成右边的 Router.to** 系列方法,全都挂在 Router 类上

2. 路由传参需要手动拼接参数、无法携带任意类型、任意大小的数据

tarojs-router-next 允许直接传递一个对象给 params,它会把 params 展开拼接到 url 后面。并且还可以接收一个 data 参数,data 可以传递任意类型、任意大小的数据。

3. 路由方法是异步的,页面通过 EventChannel 通信,事件的回调方法可读性差、耦合度高、只能在回调内部处理异常

tarojs-router-next 的路由跳转会返回一个 Promise,可以用 async/await 写出同步代码,详细参考 同步的路由方法

4. 路由跳转的鉴权等实现起来比较麻烦

自己实现路由的鉴权是比较麻烦的事情,而 tarojs-router-next 提供非常易于理解的路由中间件功能,详细参考 路由中间件

平台与框架支持

框架

支持所有 Taro 可支持的框架(ReactVueVue3Nerv

小程序

理论上支持所有 Taro 可支持的小程序平台,目前已在 微信小程序QQ小程序支付宝小程序 测试通过

H5

支持

React Native

暂不支持

友情推荐

Taroify

地址:https://github.com/mallfoundry/taroify

Taroify 是移动端组件库 Vant 的 Taro 版本,两者基于相同的视觉规范,提供一致的 API 接口,助力开发者快速搭建小程序应用。

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].