1.0.5 • Published 3 years ago

medusa-wx-router v1.0.5

Weekly downloads
8
License
MIT
Repository
github
Last release
3 years ago

medusa-wx-router

基于微信小程序路由功能 API 进行的二次封装函数,提供以同一 API 使用原生四种跳转能力的功能以及参数保真功能。

API 说明

routerTo

通用跳转函数,提供跳转与参数保真功能

参数

属性类型默认值必填说明
urlString-目标页面路径
typeStringpush跳转方式
queryObject-跳转参数
successFunction-跳转成功回调函数

示例

import ms from 'medusa-wx-router';
/** 完整调用方式 */
ms.routerTo({
  url: 'pages/home/index',
  type: 'push',
  query: {
    id: 0,
    bool: true
  },
  success: () => console.log('successfully'),
});
/** navigateTo API快捷形式 */
ms.routerTo('pages/home/index', {
  id: 0,
  bool: true
});

type 映射关系

typeAPI
pushnavigateTo
replaceredirectTo
reLaunchreLaunch
switchTabswitchTab

decoding

提供参数解析功能

参数

属性类型默认值必填说明
optionsObject-onLoad生命周期函数的参数

示例

Page({
  onLoad(options) {
    /** query对象中的属性维持了跳转前的变量类型 */
    const query = ms.decoding(options); // { id: 0, bool: true }
  }
});

back

提供回退功能

参数

属性类型默认值必填说明
deltaNumber1回退步值

示例

ms.back(delta);

goHome

返回首页功能

示例

ms.goHome();

License

MIT

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago