您现在的位置是:网站首页> 编程资料编程资料
小程序tab实现页面切换_javascript技巧_
2023-05-24
363人已围观
简介 小程序tab实现页面切换_javascript技巧_
本文实例为大家分享了小程序tab实现页面切换的具体代码,供大家参考,具体内容如下

.wxml
待接收(0)
处理中(1)
已完成(1)
{{currentIndex}} {{currentIndex}} {{currentIndex}}
.wxss
page{ width: 100%; height: 100%; } .container { height: 100%; min-height: 100%; display: flex; flex-direction: column; box-sizing: border-box; } .title { width: 100%; height: 88rpx; background: white; display: flex; align-items: center; justify-content: space-around; } .titleSel { width: 33%; color: #5f6fee; font-size: 32rpx; display: flex; flex-direction: column; align-items: center; } .titleUnsel { color: #858fab; font-size: #858fab; } .headerLineSel { background: #5f6fee; height: 6rpx; width: 40rpx; position: relative; margin-top: 10rpx; } .headerLineUnsel { background: #fff; height: 6rpx; width: 40rpx; position: relative; margin-top: 10rpx; } .colors{ width: 100%; height: 100%; } .colors1{ width: 100%; height: 100%; background-color: royalblue; } .colors2{ width: 100%; height: 100%; background-color: salmon; } .colors3{ width: 100%; height: 100%; background-color: seagreen; }.js
data: { currentIndex: 0, }, //用户点击tab时调用 titleClick: function (e) { let currentPageIndex = this.setData({ //拿到当前索引并动态改变 currentIndex: e.currentTarget.dataset.idx }) console.log(e.currentTarget.dataset.idx) },以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
您可能感兴趣的文章:
相关内容
- 浅谈vue3中ref、toRef、toRefs 和 reactive的区别_vue.js_
- JavaScript中array.reduce()数组方法的四种使用实例_javascript技巧_
- js面向对象编程OOP及函数式编程FP区别_JavaScript_
- 小程序实现tab更换页面效果_javascript技巧_
- Vue.js实现页面后退时还原滚动位置的操作方法_javascript技巧_
- 微信小程序实现时间选择_javascript技巧_
- 微信小程序实现底部弹窗_javascript技巧_
- JS高级程序设计之class继承重点详解_JavaScript_
- JS class语法糖的深入剖析_JavaScript_
- vue3 el-table结合seamless-scroll实现表格数据滚动的思路详解_vue.js_
