本文共 2025 字,大约阅读时间需要 6 分钟。
微信小程序原生的tabbar一个项目只能有一个,我想要在多个页面都能使用不同的tabbar,就找到伪tabbar这种方法,通过点击元素实现页面跳转。
新建文件夹:
tabbarStudy.wxml
个人中心
tabbarStudy.wxss
/* 伪tabBar */.tabBar { background-color: white; border-top: 1rpx solid #a9b7b7; color: "#a9b7b7"; width: 100%; height: 100rpx; position: fixed; bottom: 0rpx; display: flex; flex-direction: row; /* justify-content: space-around; */}.tabBar-left { background-color: white; color: "#a9b7b7"; width: 50%; height: 100rpx; display: flex; flex-direction: column;}.tabBar-left-content-top { background-color: white; color: "#a9b7b7"; width: 100%; height: 70rpx; display: flex; flex-direction: row; justify-content: space-around; margin-top: 10rpx;}.tabBar-left-content-img { width: 50rpx; height: 50rpx;}.tabBar-left-content-bottom { background-color: white; color: "#a9b7b7"; width: 100%; height: 30rpx; display: flex; flex-direction: row; justify-content: space-around;}.tabBar-left-content-label { text-align: center; font-size: 25rpx; line-height: 25rpx; height: 25rpx; color: #a9b7b7;}.tabBar-right { background-color: white; color: "#a9b7b7"; width: 50%; height: 100rpx; display: flex; flex-direction: column;}.tabBar-right-content-top { background-color: white; color: "#a9b7b7"; width: 100%; height: 70rpx; display: flex; flex-direction: row; justify-content: space-around; margin-top: 10rpx;}.tabBar-right-content-img { width: 50rpx; height: 50rpx;}.tabBar-right-content-bottom { background-color: white; color: "#a9b7b7"; width: 100%; height: 30rpx; display: flex; flex-direction: row; justify-content: space-around;}.tabBar-right-content-label { text-align: center; font-size: 25rpx; line-height: 25rpx; height: 25rpx; color: #a9b7b7;}
tabbarStudy.js
myCenter文件与上面的类似,不同之处
运行结果:
伪tabbar的不足:跳转的时候会出现闪烁
转载地址:http://rlssi.baihongyu.com/