Two methods of jumping pages in WeChat applet

Step 1: Add a new page

insert image description here
pagesCreate a new file under the file in the applet directory , and name it asnews

insert image description here
app.jsonAdd a new page in"pages/news/news"

insert image description here
At this time, newsfour configuration files appear under the folder.


Step 2: Jump to the page

Method 1: Navigator is added
insert image description here
on the home page of the applet, index.wxmlnamely
<navigator url="../news/news">跳转至新页面</navigator>

insert image description here
The effect is as shown in the figure above, click on this text segment to jump to a new page.


Method 2: button

insert image description here

On the home page of the applet, that is index.wxml, add <button bindtap="aaa" size="mini" type="primary">跳转至新页面</button>, which aaais a newly defined function sizeto control the size of the button.

insert image description here
Define a function in index.js, jump to a new page.

 aaa(){
    
    
  wx.navigateTo({
    
    
    url: '../news/news',
  })
  },

insert image description here
The effect is as shown in the figure, and clicking the button will jump to a new page.

Guess you like

Origin blog.csdn.net/Dax1_/article/details/108371237