Skip to content

Commit 34dfd5a

Browse files
committed
多页面跳转
1 parent 51f8b15 commit 34dfd5a

File tree

11 files changed

+157
-57
lines changed

11 files changed

+157
-57
lines changed

app.json

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
{
22
"pages": [
33
"pages/home/home",
4-
"pages/about/about"
5-
]
4+
"pages/about/about",
5+
"pages/detail/detail",
6+
"pages/comment/comment"
7+
],
8+
"tabBar": {
9+
"list": [
10+
{
11+
"pagePath": "pages/home/home",
12+
"text": "首页"
13+
},
14+
{
15+
"pagePath": "pages/about/about",
16+
"text": "关于"
17+
}
18+
]
19+
}
620
}

pages/comment/comment.js

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// pages/comment/comment.js
2+
Page({
3+
4+
/**
5+
* 页面的初始数据
6+
*/
7+
data: {
8+
9+
},
10+
11+
/**
12+
* 生命周期函数--监听页面加载
13+
*/
14+
onLoad: function (options) {
15+
16+
},
17+
18+
/**
19+
* 生命周期函数--监听页面初次渲染完成
20+
*/
21+
onReady: function () {
22+
23+
},
24+
25+
/**
26+
* 生命周期函数--监听页面显示
27+
*/
28+
onShow: function () {
29+
30+
},
31+
32+
/**
33+
* 生命周期函数--监听页面隐藏
34+
*/
35+
onHide: function () {
36+
37+
},
38+
39+
/**
40+
* 生命周期函数--监听页面卸载
41+
*/
42+
onUnload: function () {
43+
44+
},
45+
46+
/**
47+
* 页面相关事件处理函数--监听用户下拉动作
48+
*/
49+
onPullDownRefresh: function () {
50+
51+
},
52+
53+
/**
54+
* 页面上拉触底事件的处理函数
55+
*/
56+
onReachBottom: function () {
57+
58+
},
59+
60+
/**
61+
* 用户点击右上角分享
62+
*/
63+
onShareAppMessage: function () {
64+
65+
}
66+
})

pages/comment/comment.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"usingComponents": {}
3+
}

pages/comment/comment.wxml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<!--pages/comment/comment.wxml-->
2+
<text>pages/comment/comment.wxml</text>
3+
4+
<navigator open-type='navigateBack' delta="2">返回首页</navigator>

pages/comment/comment.wxss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/* pages/comment/comment.wxss */

pages/detail/detail.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// pages/detail/detail.js
2+
Page({
3+
onLoad: function (options) {
4+
console.log(options)
5+
},
6+
onUnload() {
7+
// 1.获取首页的页面对象
8+
// getCurrentPages当前所有栈的页面
9+
const pages = getCurrentPages()
10+
const home = pages[pages.length - 2]
11+
12+
// 2.调用页面对象的setData
13+
home.setData({
14+
title: '呵呵呵'
15+
})
16+
},
17+
handleBackHome() {
18+
wx.navigateBack({
19+
delta: 1
20+
})
21+
}
22+
})

pages/detail/detail.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"usingComponents": {}
3+
}

pages/detail/detail.wxml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<!--pages/detail/detail.wxml-->
2+
<text>pages/detail/detail.wxml</text>
3+
4+
<navigator url='/pages/comment/comment'>跳到评论页</navigator>
5+
6+
<navigator open-type='navigateBack'>返回</navigator>
7+
8+
<button size='mini' bind:tap="handleBackHome">返回</button>

pages/detail/detail.wxss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/* pages/detail/detail.wxss */

pages/home/home.js

Lines changed: 8 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -5,62 +5,15 @@ Page({
55
* 页面的初始数据
66
*/
77
data: {
8-
9-
},
10-
11-
/**
12-
* 生命周期函数--监听页面加载
13-
*/
14-
onLoad: function (options) {
15-
16-
},
17-
18-
/**
19-
* 生命周期函数--监听页面初次渲染完成
20-
*/
21-
onReady: function () {
22-
23-
},
24-
25-
/**
26-
* 生命周期函数--监听页面显示
27-
*/
28-
onShow: function () {
29-
8+
title: '哈哈哈'
309
},
10+
handlePushDetail() {
11+
wx.navigateTo({
12+
url: '/pages/detail/detail?title=你好啊',
13+
})
3114

32-
/**
33-
* 生命周期函数--监听页面隐藏
34-
*/
35-
onHide: function () {
36-
37-
},
38-
39-
/**
40-
* 生命周期函数--监听页面卸载
41-
*/
42-
onUnload: function () {
43-
44-
},
45-
46-
/**
47-
* 页面相关事件处理函数--监听用户下拉动作
48-
*/
49-
onPullDownRefresh: function () {
50-
51-
},
52-
53-
/**
54-
* 页面上拉触底事件的处理函数
55-
*/
56-
onReachBottom: function () {
57-
58-
},
59-
60-
/**
61-
* 用户点击右上角分享
62-
*/
63-
onShareAppMessage: function () {
64-
15+
// wx.redirectTo({
16+
// url: '',
17+
// })
6518
}
6619
})

0 commit comments

Comments
 (0)