Home  >  Article  >  WeChat Applet  >  How to jump to a specified mini program page from outside the mini program_get the link from the mini program page

How to jump to a specified mini program page from outside the mini program_get the link from the mini program page

php是最好的语言
php是最好的语言Original
2018-07-28 14:17:2915467browse

The links in the mini program use the navigator component

Use the a tag in html, the a tag can link to any address on the network

But the navigator in the mini program can only Applied to the link jump of in the current applet

<navigator url="http://www.baidu.com">跳转A</navigator>

<navigator url=&#39;test/t&#39;>跳转B</navigator>
The first one is invalid

The second one can jump correctly, it is required Note: The page in the url cannot be the page

in tabBar (bottom menu), but you can set the

redirect attribute through the open-type attribute to open a new page When,

Close the original page

(In the new page, you cannot return to the original page)

<navigator redirect url=&#39;test/t&#39;>跳转</navigator>
When jumping, pass the parameters (

No need to add quotation marks , double quotation marks will be added automatically, otherwise there will be one extra quotation mark, so directly write: id=111&name=张三):

<navigator  url=&#39;test/t?id=111&name=张三&#39;>跳转</navigator>
passed

onLoad

The event gets the url parameters and automatically puts the parameters into it when loading this page

<navigator  url=&#39;test/t?id=111&name=张三&#39; hover-class=&#39;hoverClass&#39;>跳转</navigator>    <!--链接1-->
<navigator  url=&#39;test/t?id=123&name=小明&#39;>跳转</navigator>    <!--链接2-->
Page({
  data: {

  },
  onLoad : function(datas) {
    console.log(datas);
  }
})
If you click link 1, the value of datas is {id: "111", name: "张Three"}, click link 2, then the value of datas is {id: "123", name: "Xiao Ming"}

hover-class is the style after clicking on it

wx.navigateTo

This Api can also complete page jump, which is the same as navigator (without redirect attribute)

<button size=&#39;mini&#39; bindtap="navigator">跳转</button>
navigator : function() {
    wx.navigateTo({
      url: &#39;test/t?id=100&user=xiaoming&#39;,
      success : function(e) {
        console.log(e.errMsg);
      }
    })
  }

wx.redirectTo

This Api can also complete page jump, which is the same as navigator (with redirect attribute), and the operation is the same as above

wx.navigateBack

This Api is used to return , Return to the upper-level page from the current page (according to the following parameters)

Page({
  data: {

  },
  back : function() {
    wx.navigateBack({
      delta : 1            // 值为1, 则是返回上一级, 值为2就返回上两级...
    })
  }
})

If the value of dellta is 1, you do not need to write the dellta attribute: wx.navigateBack({})

If the value of dellta If the value exceeds the total level that

can be returned

, it will return to the home pageRelated articles:

Link to this page

WeChat Mini Program Component: Navigator Page Link Interpretation and Analysis

Related Videos:

Page Links and Multimedia-WeChat Mini Program Program project practical video tutorial

The above is the detailed content of How to jump to a specified mini program page from outside the mini program_get the link from the mini program 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