<navigator url="../detail/detail">跳转页面</navigator>
使用点击事件,bindtap会出现冒泡,用catchtap可阻止冒泡事件
<view bindtap="clickA">点击</view>
Page({
clickA: function() {
wx.navigateTo({
url: '../detail/detail'
})
},
wx.redirectTo({
url: '../detail/detail'
})
clickA: function () {
wx.switchTab({
url: '../reader/reader'
})
},
})
如果要传递参数,比如id
<navigator url="../courses-detail/courses-detail?id=1">
<view class='course-title'>photoshop研习社</view>
</navigator>
在对应的页面(courses-detail)js中接受在onLoad 的options中:
onLoad: function (options) {
this.setData({
id:options['id']
})
},
也可以使用点击函数传递参数(id)
<view bindtap='changePost' data-id='2'>这一篇</view>
changePost: function (event) {
var id = event.currentTarget.dataset.id;
wx.navigateTo({
url: '../detail/detail?id=' + id
});
console.log(666, event.currentTarget.dataset.id)
},
Congratulations @lemooljiang! You have completed the following achievement on the Hive blockchain and have been rewarded with new badge(s) :
Your next target is to reach 1400 posts.
Your next target is to reach 39000 upvotes.
You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word
STOPCheck out the last post from @hivebuzz:
Support the HiveBuzz project. Vote for our proposal!