微信小程序 选项卡的简单实例
看下效果
代码:
home.wxml
<swiper current="{{currentTab}}" class="swiper-Box" duration="300" style="height:{{winHeight - 80}}px" bindchange="bindChange">
home.wxss
.swiper-Box{ display: block; height: 100%; width: 100%; overflow: hidden; }
.swiper-Box view{
text-align: center;
}
.swiper-Box view{
text-align: center;
}
home.js
winWidth: 0,winHeight: 0,// tab切换
currentTab: 0,},onLoad: function () {
var that = this;
currentTab: 0,},onLoad: function () {
var that = this;
wx.getSystemInfo({
success: function (res) {
that.setData({
winWidth: res.windowWidth,winHeight: res.windowHeight
});
}
});
},bindChange: function (e) {
var that = this;
that.setData({ currentTab: e.detail.current });
},swichNav: function (e) {
var that = this;
if (this.data.currentTab === e.target.dataset.current) {
return false;
} else {
that.setData({
currentTab: e.target.dataset.current
})
}
}
})
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!