{{item.text}}
{{item.text}}
<ol start="3">
{
"component": true,"usingComponents": {}
}
- wxss中:设置底部导航栏的基本样式以及兼容iphoneX及更高版本的样式
.tabbar_box{
font-size: 22rpx;
display: flex;
flex-direction: row;
justify-content: space-around;
position: fixed;
bottom: 0;
left: 0;
z-index: 999;
width: 100%;
height: 98rpx;
box-shadow: 0 0 16px 2px rgba(199,199,0.40);
}
.tabbar_box.iphoneX-height{
padding-bottom: 68rpx;
}
.middle-wrapper{
position: absolute;
right: 310rpx;
bottom: 0;
background-color: #fff;
width: 120rpx;
height: 120rpx;
border-radius: 50%;
border-top: 2rpx solid #f2f2f3;
}
.middle-wrapper.iphoneX-height{
bottom: 68rpx;
}
.tabbar_nav{
flex: 1;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100%;
position: relative;
}
.tabbar_icon,.special-text-wrapper{
width: 40rpx;
height: 40rpx;
margin-bottom:10rpx
}
.special-wrapper{
position: absolute;
left: 77rpx;
top: -45rpx;
width: 106rpx;
height: 106rpx;
border-radius: 50%;
border-top: 2rpx solid #f2f2f3;
background-color: #fff;
text-align: center;
box-sizing: border-box;
padding: 8rpx;
}
.special-wrapper .tabbar_icon{
width: 90rpx;
height: 90rpx;
}
<ol start="5">
// tabBarComponent/tabBar.js
import wepy from 'wepy';
Component({
/**
- 组件的属性列表
*/
properties: {
tabbar: {
type: Object,value: {
'backgroundColor': '#ffffff','color': '#979795','selectedColor': '#1c1c1b','list': [
{
'pagePath': 'pages/index/index','iconPath': 'https://rplatform.oss-cn-beijing.aliyuncs.com/smallprogram/basic/home_def@2x.png','selectedIconPath': 'https://rplatform.oss-cn-beijing.aliyuncs.com/smallprogram/basic/home_sel@2x.png','text': '首页'
},{
'pagePath': 'pages/assemble/assemble','iconPath': 'https://rplatform.oss-cn-beijing.aliyuncs.com/smallprogram/basic/fabu@2x.png','isSpecial': true,'text': '发布拼团'
},{
'pagePath': 'pages/user/user','iconPath': 'https://rplatform.oss-cn-beijing.aliyuncs.com/smallprogram/basic/my_def@2x.png','selectedIconPath': 'https://rplatform.oss-cn-beijing.aliyuncs.com/smallprogram/basic/my_sel@2x.png','text': '我的'
}
]
}
},showOrHide: {
type: Boolean,value: true
}
},/**
- 组件的初始数据
*/
data: {
isIphoneX: wepy.$instance.globalData.systemInfo.model.toLowerCase().includes('iPhone X'.toLowerCase())
},/**
- 组件的方法列表
*/
methods: {
navTo(e) {
wepy.switchTab({
url: e.currentTarget.dataset.url,success(e) {
console.log(e);
},fail(e) {
console.log(e,'err');
}
});
}
},onLoad(){
}
});
<ol start="6">
getSystemInfo() {
let self = this;
wepy.getSystemInfo({
success: function (res) {
self.globalData.systemInfo = res;
console.log(res,res.model.toLowerCase().includes('iPhone X'.toLowerCase()));
self.globalData.isIphoneX = res.model.toLowerCase().includes('iPhone X'.toLowerCase())
}
});
}
- 然后在需要底部导航栏的页面中引入即可。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。