全部产品
Search
文档中心

SuperApp:路由

更新时间:Aug 06, 2025

本文介绍路由相关的JSAPI,供您创建H5端应用或者小程序时参考。包括退出当前页面、打开一个新的小程序界面的能力。

WVNavigator.pop

退出当前页面。

输入参数

  • 自定义:如果传入的参数为空,调用系统默认的页面退出模式;如果自定义实现了NavigatorAdapter,需要根据自定义实现的逻辑进行传参。

回调参数

成功回调参数:

  • 无回调参数。

失败回调参数:

  • [string] msg:错误信息。

window.WindVane.call('WVNavigator', 'pop', null, function(e) {
}, function(e) {
        alert('failure: ' + JSON.stringify(e));
});

WVNavigator.push

打开新页面。

输入参数

  • 如果自定义实现了NavigatorAdapter,需要根据自定义实现的逻辑进行传参。

  • 如果未自定义实现NavigatorAdapter,需要传入以下参数。

    [string] url:需要打开的小程序页面的URL。

回调参数

成功回调参数:

  • 无回调参数。

失败回调参数:

  • [string] msg:错误信息。

var params = {
  url: 'xxxx'
};
window.WindVane.call('WVNavigator', 'push', params, function(e) {
}, function(e) {
        alert('failure: ' + JSON.stringify(e));
});

wv.navigateToMiniApp

从当前小程序跳转至另外一个小程序。

输入参数

  • [string] appId:小程序ID。

  • [string] path: 指定跳转的小程序页面,如果是跳转到根目录,则无需设置。

  • [object] extraData: 该对象会被转换为页面的query参数拼接在path后面,如果要跳转的页面不需要任何的query,则无需设置。

回调参数

成功回调参数:

  • 无回调参数。

失败回调参数:

  • [string] msg:错误信息。

window.WindVane.call(
  "wv",
  "navigateToMiniApp",
  {
    // miniapp id
    appId: "2123xxxxxx",
    // which page to navigate, if navigate to the index page, then this param can be empty
    path: "/product/list",
    // this object will parse as the query after the navigate path, if the navigate page doesn't need the query, this param can be empty
    extraData: {
      source: "APP01"
    }
  },
  function () {
    console.log('open miniapp successfully');
  },
  function (msg) {
    console.log('open miniapp error', msg);
  }
);