JavaScript APIs for navigating between pages in HTML5 apps and Miniapps: close the current page, open a new page, or launch a different Miniapp.
WVNavigator.pop
Closes the current page.
Input parameters
Custom: Pass
NavigatorAdapterparameters to close the page using a custom implementation. If no parameters are passed, the page closes in the default mode.
Callback parameters
Parameters for a success callback:
None.
Parameters for a failure callback:
[
string] msg: the error message.
window.WindVane.call('WVNavigator', 'pop', null, function(e) {
}, function(e) {
alert('failure: ' + JSON.stringify(e));
});
WVNavigator.push
Opens a new page.
Input parameters
If you are implementing the
NavigatorAdapterAPI with custom methods, specify the parameters required by your implementation.-
If you are using the default implementation, specify the following parameter.
[
string] url: the URL of the Miniapp page to open.
Callback parameters
Parameters for a success callback:
None.
Parameters for a failure callback:
[
string] msg: the error message.
var params = {
url: 'xxxx'
};
window.WindVane.call('WVNavigator', 'push', params, function(e) {
}, function(e) {
alert('failure: ' + JSON.stringify(e));
});
wv.navigateToMiniapp
Launches another Miniapp from the current Miniapp.
Input parameters
[
string] appId: the ID of the target Miniapp.[
string] path: the page path to open in the target Miniapp. If left blank, the index page opens. Optional.[
object] extraData: additional data passed as query parameters to the target page. Omit this field if the target page requires no query parameters. Optional.
Callback parameters
Parameters for a success callback:
None.
Parameters for a failure callback:
[
string] msg: the error message.
window.WindVane.call(
"wv",
"navigateToMiniapp",
{
// Miniapp ID
appId: "2123xxxxxx",
// Page path to open; leave blank to open the index page
path: "/product/list",
// Additional data passed as query parameters; omit if not needed
extraData: {
source: "APP01"
}
},
function () {
console.log('open Miniapp successfully');
},
function (msg) {
console.log('open Miniapp error', msg);
}
);