为什么wx.navigateTo可以跳转, wx.switchTab没反应
来源:3-3 项目作业
weixin_慕村8435682
2019-08-18 16:10:19
<view class="container">
<image class="avatar" src="/images/avatar/1.png"></image>
<text class="motto">Hello, 七月</text>
<view class="journey-container" bindtap="onTap">
<text class="journey">开启小程序之旅</text>
</view>
</view>
Page({
onTap: function (event) {
// wx.navigateTo({
// url:"../post/post"
// });
wx.switchTab({
url:"../post/post"
});
}
})
{
"navigationBarBackgroundColor": "#b3d4db"
}
.container{
display: flex;
flex-direction:column;
align-items: center;
background-color:#b3d4db;
}
.avatar{
width:200rpx;
height:200rpx;
margin-top:160rpx;
}
.motto{
margin-top:100rpx;
font-size:32rpx;
font-weight: bold;
}
.journey-container{
margin-top: 200rpx;
border: 1px solid #405f80;
width: 200rpx;
height: 80rpx;
border-radius: 5px;
text-align:center;
}
.journey{
font-size:22rpx;
font-weight: bold;
line-height:80rpx;
color: #405f80;
}
page{
height: 100%;
background-color:#b3d4db;
}
1回答
同学你好, 首先我们要了解这两个方法的区别
wx.switchTab表示只能跳转到tab页面
wx.navigateTo表示可以跳转到任何一个页面
建议: 同学检查一下是否配置了tab页面。
老师这里举个简单的示例, 在app.json中配置tabBar选项,这个方法老师在视频中有详细的讲解, 同学如果就不清楚,可以回顾一下视频哦。 示例:switchTab方法只能跳转到如下所示的tab页
如果帮助到了你, 欢迎采纳!
祝学习愉快~~~
相似问题