当前位置:网站首页>小程序滑动、点击切换简洁UI
小程序滑动、点击切换简洁UI
2022-07-07 07:08:00 【德宏大魔王】
系列文章目录
【零基础微信小程序入门开发】小程序介绍及环境搭建
【零基础微信小程序入门开发】配置小程序
【零基础微信小程序入门开发】小程序框架一
【零基础微信小程序入门开发】小程序框架二
【零基础微信小程序入门开发】基础能力(一)
【零基础微信小程序入门开发】基础能力(二)
小程序滑动、点击切换简洁UI
开发遇到了,就简单的记录下,小程序滑动或者点击切换样式

这里不做演示了,直接上代码
wxml
<view>
<!-- Tab布局 -->
<view class='navBox'>
<view class='titleBox' bindtap='titleClick' data-idx='0'>
<text class="{
{0 == currentIndex ? 'fontColorBox' : ''}}">安卓</text>
<hr class="{
{0 == currentIndex ? 'lineBox' : 'notLineBox'}}" />
</view>
<view class='titleBox' bindtap='titleClick' data-idx='1'>
<text class="{
{1 == currentIndex ? 'fontColorBox1' : ''}}">苹果</text>
<hr class="{
{1 == currentIndex ? 'lineBox' : 'notLineBox'}} " />
</view>
</view>
<!-- 内容布局 -->
<swiper class='swiperTtemBox' bindchange='pagechange' current='{
{currentIndex}}'>
<swiper-item class='swiperTtemBox'>
<view>内容1</view>
</swiper-item>
<swiper-item class='swiperTtemBox'>
<view>内容2</view>
</swiper-item>
</swiper>
</view>
js
const app = getApp()
Page({
data: {
currentIndex: 0, //默认第一个
},
pagechange: function (ee) {
if ("touch" === ee.detail.source) {
let currentPageIndex = this.data.currentIndex;
currentPageIndex = (currentPageIndex + 1) % 2;
this.setData({
currentIndex: currentPageIndex,
})
}
},
//点击tab时触发
titleClick: function (e) {
this.setData({
//拿到当前索引并动态改变
currentIndex: e.currentTarget.dataset.idx
})
},
})
需要写的代码放在内容1替换即可,即可实现轻松的点击或者滑动切换窗口,js数据交互统一处理即可,同一加载只是显示的排版布局而已,其他一样的
️️️️️️ 🥳🥳🥳 茫茫人海千千万万,感谢这一刻你看到了我的文章,感谢观赏,大家好呀,欢迎加入人工智能交流群(看我的动态),更多周边福利等你🥳🥳🥳
欢迎订阅本专栏或者关注我,大家一起努力每天一题算法题
️️️ 最后,希望我的这篇文章能对你的有所帮助!
愿自己还有你在未来的日子,保持学习,保持进步,保持热爱,奔赴山海! ️️️
边栏推荐
- The difference between viewpager2 and viewpager and the implementation of viewpager2 in the rotation chart
- Zen - batch import test cases
- [4G/5G/6G专题基础-147]: 6G总体愿景与潜在关键技术白皮书解读-2-6G发展的宏观驱动力
- 根据热门面试题分析Android事件分发机制(二)---事件冲突分析处理
- Oracle安装增强功能出错
- 第一讲:包含min函数的栈
- Jenkins automated email
- Over 100000 words_ Ultra detailed SSM integration practice_ Manually implement permission management
- flinkcdc 用sqlclient可以指定mysqlbinlog id执行任务吗
- thinkphp数据库的增删改查
猜你喜欢

How does mongodb realize the creation and deletion of databases, the creation of deletion tables, and the addition, deletion, modification and query of data

其实特简单,教你轻松实现酷炫的数据可视化大屏

Network request process

Unity3d interface is embedded in WPF interface (mouse and keyboard can respond normally)

VSCode+mingw64

sqlplus乱码问题,求解答

Elaborate on MySQL mvcc multi version control

Unity shader (basic concept)

Lecture 1: stack containing min function

第一讲:包含min函数的栈
随机推荐
Netease cloud wechat applet
Sublime Text4 download the view in bower and set the shortcut key
Regular matching starts with XXX and ends with XXX
scrapy爬虫mysql,Django等
Yapi test plug-in -- cross request
shake数据库中怎么使用Mongo-shake实现MongoDB的双向同步啊?
Information Security Experiment 4: implementation of IP packet monitoring program
根据热门面试题分析Android事件分发机制(一)
What development models did you know during the interview? Just read this one
信息安全实验四:Ip包监视程序实现
flinkcdc 用sqlclient可以指定mysqlbinlog id执行任务吗
sqlplus乱码问题,求解答
如何成为一名高级数字 IC 设计工程师(5-2)理论篇:ULP 低功耗设计技术精讲(上)
软件建模与分析
IIS faked death this morning, various troubleshooting, has been solved
如何成为一名高级数字 IC 设计工程师(1-6)Verilog 编码语法篇:经典数字 IC 设计
12、 Sort
Pick up the premise idea of programming
沙龙预告|GameFi 领域的瓶颈和解决方案
The difference between viewpager2 and viewpager and the implementation of viewpager2 in the rotation chart
