tencent cloud

Feedback

Last updated: 2024-11-21 18:41:53

    switchTab

    This API is used via wx.switchTab(Object object).
    Feature Description: Redirects to the tabBar page, simultaneously closing all other non-tabBar pages.
    Parameter and Description: Object.
    Attribute
    Type
    Default value
    Required
    Description
    url
    string
    -
    Yes
    The path to the tabBar page that needs to be redirected (code package path) (must be defined on the page in the tabBar field of app.json). The path cannot carry parameters.
    success
    function
    -
    No
    Callback Function of Successful Interface Call
    fail
    function
    -
    No
    Callback Function of Successful Interface Call
    complete
    function
    -
    No
    Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations)
    Sample Code
    // app.json
    {
    "tabBar": {
    "list": [{
    "pagePath": "index",
    "text": "Homepage"
    },{
    "pagePath": "other",
    "text": "Other"
    }]
    }
    }
    wx.switchTab({
    url: '/index'
    })

    reLaunch

    This method is used via wx.reLaunch(Object object).
    Feature Description: Closes all pages and opens a specific page within the application.
    Parameter and Description: Object.
    Attribute
    Type
    Default value
    Required
    Description
    url
    string
    -
    Yes
    The path to a non-tabBar page within the application to which you want to redirect (code package path). This path can be followed by parameters. Parameters are separated from the path by a ?, with parameter keys and values connected by a =, and different parameters separated by a &. For example, 'path?key=value&key2=value2'
    success
    function
    -
    No
    Callback Function of Successful Interface Call
    fail
    function
    -
    No
    Callback Function of Failing Interface Call
    complete
    function
    -
    No
    Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations)
    Sample Code
    wx.reLaunch({
    url: 'test?id=1'
    })

    redirectTo

    This API is used via wx.redirectTo(Object object).
    Feature Description: Close the current page and jump to a page within the app. However, it is not allowed to jump to a tabbar page.
    Parameter and Description: Object.
    Attribute
    Type
    Default value
    Required
    Description
    url
    string
    -
    Yes
    The path to a page within the application to which you want to redirect (code package path). This path can be followed by parameters. Parameters are separated from the path by a ?, with parameter keys and values connected by a =, and different parameters separated by a &. For example, 'path?key=value&key2=value2'
    success
    function
    -
    No
    Callback Function of Successful Interface Call
    fail
    function
    -
    No
    Callback Function of Failing Interface Call
    complete
    function
    -
    No
    Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations)
    Sample Code
    wx.redirectTo({
    url: 'test?id=1'
    })
    This API is used via wx.navigateTo(Object object).
    Feature Description: Retains the current page and redirects to a specific page within the application, but cannot redirect to a tabbar page. Using wx.navigateBack allows a return to the original page. The page stack in the mini program can be up to ten layers deep.
    Parameter and Description: Object.
    Attribute
    Type
    Default value
    Required
    Description
    url
    string
    -
    Yes
    The path to the non-tabBar page within the application to which you want to navigate (code package path). This path can be followed by parameters. Parameters are separated from the path by a ?, parameter keys and values are connected by an equals sign, and different parameters are separated by a &; for example, 'path?key=value&key2=value2'
    success
    function
    -
    No
    Callback Function of Successful Interface Call
    fail
    function
    -
    No
    Callback Function of Failing Interface Call
    complete
    function
    -
    No
    Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations)
    Sample Code
    wx.navigateTo({
    url: 'test?id=1',
    })
    
    
    //test.js
    Page({
    onLoad: (option){
    console.log(option.query)
    }
    })
    This API is used via wx.navigateBack(Object object).
    Feature Description: Close the current page, return to the previous page or multi-level page, you can get the current page stack by getCurrentPages, decide how many levels you need to return.
    Parameter and Description: Object.
    Attribute
    Type
    Default value
    Required
    Description
    delta
    number
    1
    No
    The number of pages returned. If delta exceeds the number of existing pages, it will return to the home page.
    success
    function
    -
    No
    Callback Function of Successful Interface Call
    fail
    function
    -
    No
    Callback Function of Failing Interface Call
    complete
    function
    -
    No
    Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations)
    Sample Code
    // Note: When calling navigateTo for navigation, the page that calls this method will be added to the stack, whereas the redirectTo method will not. See the example code below.
    
    // This is page A
    wx.navigateTo({
    url: 'B?id=1'
    })
    
    // This is page B
    wx.navigateTo({
    url: 'C?id=1'
    })
    
    // Perform navigateback within page C will return to page A.
    wx.navigateBack({
    delta: 2
    })

    EventChannel

    Inter-page event communication channel.

    EventChannel.emit

    This method is used via EventChannel.emit(string eventName, any args).
    Feature Description: Triggers an event.
    Parameter and Description: string eventName, event name; any args, event parameter.

    EventChannel.off

    This method is used via EventChannel.off(string eventName, EventCallback fn).
    Feature Description: Cancels the monitoring of an event. When a second parameter is provided, only the specified monitoring function is canceled; otherwise, all monitoring functions are canceled. The method is used via EventChannel.off(string eventName, function fn).
    Parameter and Description: string eventName, event name; function fn, event listener function; any args, parameters of triggered event.

    EventChannel.on

    This method is used via EventChannel.on(string eventName, EventCallback fn).
    Feature Description: Continuously monitors an event. This method is used via EventChannel.on(string eventName, function fn).
    Parameter and Description: string eventName, event name; function fn, event listener function; any args, parameters of triggered event.

    EventChannel.once

    This method is used via EventChannel.once(string eventName, EventCallback fn)
    Feature Description: Monitors an event once, becoming invalid after triggering. This method is used via EventChannel.once(string eventName, function fn).
    Parameter and Description: string eventName, event name; function fn, event listener function; any args, parameters of triggered event.
    
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support