Summary of five page jump methods for WeChat applets

The first type: <navigator></navigator> tag.

This is the most common way of jumping, which is equivalent to the a tag in html. But it should be noted that this method cannot jump to the tabbar page.

The format is:

1

<navigator url="........"></navigator>

The second type: wx.navigateTo.

By constructing the js function, calling this interface in the function can realize the effect of page jump. But this interface can not jump to the tabbar page either. After the jump, there is a small return arrow in the upper left corner, click to return to the original page.

The format is:

1

<view class="select_calculator" bindtap="next_calculator">

1

2

3

4

5

6

next_calculator:function () {

    wx.navigateTo({

      url: '/pages/calculator/calculator',

    })

  

  },

The third type: wx.redirectTo.

 Close the current page and jump to a page in the application (you cannot jump to the tabbar page). similar to in html window.open('.....');

After jumping, a small return arrow appears in the upper left corner, and you can return to the original page after clicking.

The fourth type: wx.switchTab.

Jump to the tabBar page and close all other non-tabBar pages; this method can only jump to the tabbar page.

For example:

js: 

1

2

3

4

5

6

7

  post_calculator:function () {

    wx.switchTab({

      url: '/pages/calculator/calculator',

    })

  },

  

})

Fifth: wx.reLaunch.

Close all pages and open to a page within the app.

The return arrow will not  wx.redirectTo appear in the upper left corner, but the two are not exactly the same;

Guess you like

Origin blog.csdn.net/qq_27981847/article/details/131984909