效果:

demo示例:
wxml:
<view bindtap="bindViewTap" class="up"> 我要綁定事件來跳轉(zhuǎn)了 </view> |
js:
Page({
data: {
},
//事件處理函數(shù)
bindViewTap: function() {
wx.navigateTo({
url: '../site/site'
})
},
onLoad: function() {
},
})
|
wxss:
.up {
height: 80rpx;
line-height: 80rpx;
background:#44b0fc;
color: #fff;
text-align: center;
}
|
wxml和樣式同上 js:
Page({
data: {
},
//事件處理函數(shù)
bindViewTap: function() {
//2:關(guān)閉當前頁面(無返回按鈕)
wx.redirectTo({
url: '../site/site'
})
},
onLoad: function() {},
})
|
遇到第一種wx.navigateTo 不跳轉(zhuǎn)問題的時候(大多數(shù)是因為想要跳的界面是對應(yīng)底部的導(dǎo)航,所以沒有反應(yīng);這個時候,就需要用到這種方法了) js:
Page({
data: {},
//事件處理函數(shù)
bindViewTap: function() {
//3:跳轉(zhuǎn)到tabBar頁面(底部導(dǎo)航)
//這種方法通常 是遇到wx.navigateTo 不跳轉(zhuǎn)問題的時候(大多數(shù)是跳的底部的導(dǎo)航,所以沒有反應(yīng))
wx.switchTab({
url: '../me/me'
})
},
onLoad: function() {},
})
|