Home  >  Article  >  WeChat Applet  >  Code example for implementing WeChat applet routing to jump to a specified page

Code example for implementing WeChat applet routing to jump to a specified page

Y2J
Y2JOriginal
2017-05-02 10:06:303112browse

Code example for implementing WeChat applet routing to jump to a specified page

How to implement WeChat applet routing to jump to a specified page? There are three forms of routing jumps for WeChat mini programs. The navigator component is used in the page to make routing jumps in the form of page links. In js, wx.navigateTo can be used to retain the current page and jump to a certain page in the application, wx. redirectTo--Close the current page and jump to a page within the application wx.navigateBack()--Close the current page and go back to the previous page.

The navigator component makes page links

Page links.

Code example for implementing WeChat applet routing to jump to a specified page

Note: The default background color of navigator-hover is {background-color: rgba(0, 0, 0, 0.1); opacity: 0.7;}, and the background color of the child node should be For transparent color

Sample code:

/** wxss **//** 修改默认的navigator点击态 **/
.navigator-hover 
{    
color:blue;
}
/** 自定义其他点击态样式类 **/
.other-navigator-hover 
{    
color:red;
}
 跳转到新页面  在当前页打开(关闭了当前页面)
 {{title}}  点击左上角返回回到之前页面
 {{title}}  点击左上角返回回到上级页面
// redirect.js navigator.jsPage({  onLoad: function(options) {    this.setData({      title: options.title }) }})
wx.navigateTo(OBJECT)

Keep the current page, jump to a page in the application, and use wx.navigateBack to return to the original page.

OBJECT parameter description:

Code example for implementing WeChat applet routing to jump to a specified page

Sample code:

wx.navigateTo({  url: 'test?id=1'})

Note: In order not to cause trouble to users when using the mini program, we It is stipulated that the page path can only be five levels, so please try to avoid multi-level interactions.

wx.redirectTo(OBJECT)

Close the current page and jump to a page within the application.

OBJECT parameter description:

Code example for implementing WeChat applet routing to jump to a specified page

Sample code:

wx.redirectTo({  url: 'test?id=1'})
wx.navigateBack()

Close the current page and go back to the previous page.

The above is the detailed content of Code example for implementing WeChat applet routing to jump to a specified page. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn