全部產品
Search
文件中心

SuperApp:路由

更新時間:Aug 07, 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);
  }
);