Skip to content

Route

switchTab

Base library support from 1.3.9, iOS version 2.1.23, Android version 2.1.38

switchTab(Object object)

Jump to tabBar Page, and close all other non - tabBar page

parameter

Object object

attributetypeDefault valuesRequiredIntroductions
urlstringyesNeed to jump tabBar Page path (Code packet path)(Required in app.json of tabBar Field defined page), cannot take parameters after path.
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

sample code

json
{
  "tabBar": {
    "list": [
      {
        "pagePath": "/pages/home/home",
        "text": "Home page"
      },
      {
        "pagePath": "/pages/other/other",
        "text": "Other"
      }
    ]
  }
}

reLaunch

Base library support from 1.3.9, iOS version 2.1.23, Android version 2.1.38

reLaunch(Object object)

Close all pages and open to a page in the app

parameter

Object object

attributetypeDefault valuesRequiredIntroductions
urlstringyesPage paths within the application that you want to jump to (Code packet path), can be followed by a path with parameters. Between parameters and pathsThe parameter key is connected with the parameter value by =, and the different parameters are separated by &Such as 'pathkey=value&key2=value2'
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

sample code

javascript
ft.reLaunch({
  url: '/pages/other/other'
})

redirectTo

Base library support from 1.3.9, iOS version 2.1.23, Android version 2.1.38

redirectTo(Object object)

Close the current page and jump to a page within the app. But you are not allowed to jump to Tabs Page

parameter

Object object

attributetypeDefault valuesRequiredIntroductions
urlstringyesNeed to jump within the application tabBar Path to the page of (Code packet path), Path can be followed with parameters. Between parameters and paths `` Delimits parameter keys with parameter values = Connected, with different parameters & SeparateSuch as 'pathkey=value&key2=value2'
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

sample code

javascript
ft.redirectTo({
  url: '/pages/other/other'
})

Base library support from 1.3.9, iOS version 2.1.23, Android version 2.1.38

navigateTo(Object object)

Keep the current page and jump to a page within your application. But you can't jump Tabs Page. use ft.navigateBack You can go back to the original page. The page stack in the Mini Program has up to ten layers

parameter

Object object

attributetypeDefault valuesRequiredIntroductions
urlstringyesNeed to jump within the application tabBar Path to the page of (Code packet path), Path can be followed with parameters. Between parameters and paths `` Delimits parameter keys with parameter values = Connected, with different parameters & SeparateSuch as 'pathkey=value&key2=value2'
eventsObjectnoInterpage communication interface, used to listen to open pages sent to the current page data. Base library 2.7.3 Start supporting.
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

object.success callback

parameter

attributetypeIntroductions
eventChannelEventChannelTo communicate with the opened page

sample code

javascript
ft.navigateTo({
  url: 'test?id=1',
  events: {
    // Adds a listener for the specified event to get the data sent to the current page by the open page
    acceptDataFromOpenedPage: function(data) {
      console.log(data)
    },
    someEvent: function(data) {
      console.log(data)
    }
    ...
  },
  success: function(res) {
    // Transfer data to the open page via the event channel
    res.eventChannel.emit('acceptDataFromOpenerPage', { data: 'test' })
  }
})
javascript
//test.js
Page({
  onLoad: function(option){
    console.log(option.query)
    const eventChannel = this.getOpenerEventChannel()
    eventChannel.emit('acceptDataFromOpenedPage', {data: 'test'});
    eventChannel.emit('someEvent', {data: 'test'});
    // Listen for the acceptDataFromOpenerPage event to get the data from the previous page passed through the eventChannel to the current page
    eventChannel.on('acceptDataFromOpenerPage', function(data) {
      console.log(data)
    })
  }
})

Base library support from 1.3.9, iOS version 2.1.23, Android version 2.1.38

navigateBack(Object object)

Closes the current page to return to the previous page or multiple levels. Can be passed getCurrentPages Get the current page stack and decide how many layers to return

parameter

Object object

attributetypeDefault valuesRequiredIntroductions
deltanumbernoNumber of pages returned, if delta Is greater than the number of existing pages, return to the home page
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

sample code

javascript
// Note: Call navigateTo When jump, the page that calls this method is added to the stack, and redirectTo Method does not. See example code below

// This is page A.
ft.navigateTo({
  url: 'Bid=1'
})

// This is page B.
ft.navigateTo({
  url: 'Cid=1'
})

// On page C NavigateBack will return to page A
ft.navigateBack({
  delta: 2
})

EventChannel

Inter-page event communication channel

EventChannel.emit

EventChannel.emit(string eventName, any args)

Trigger an event

parameter

string eventName

Event Name

any args

Event parameter

EventChannel.off

EventChannel.off(string eventName, function fn)

Cancel listening on an event. When the second argument is given, cancel only the given listener function, otherwise cancel all listener functions

parameter

string eventName

Event Name

function fn

Event listener function

EventChannel.on

EventChannel.on(string eventName, function callback)

Continuously monitor an event

parameter

string eventName

Event Name

function callback

The callback function that the event listens to

EventChannel.once

EventChannel.once(string eventName, function fn)

Monitor an event once, trigger and fail

parameter

string eventName

Event Name

function callback

The callback function that the event listens to