赞
踩
"tabBar": { "color": "#cccccc", "selectedColor": "#2979ff", "borderStyle": "black", "backgroundColor": "#ffffff", "list": [ { "pagePath": "pages/message/index", "iconPath": "static/tabbar/5.png", "selectedIconPath": "static/tabbar/5-5.png", "text": "消息" }, { "pagePath": "pages/home/index", "iconPath": "static/tabbar/logo.jpeg", "selectedIconPath": "static/tabbar/logo.jpeg", "text": "" }, { "pagePath": "pages/my/index", "iconPath": "static/tabbar/6.png", "selectedIconPath": "static/tabbar/6-6.png", "text": "我的" } ] }
// 底部tabbar
.uni-tabbar__item:nth-child(3) .uni-tabbar__icon {
width: 36px !important;
height: 36px !important;
}
uni.setTabBarBadge({
index: 0,
text: '2'
})
<template> <u-tabbar :value="tab" @change="changeTab" :fixed="true" :border="true" :placeholder="true" :safeAreaInsetBottom="true"> <u-tabbar-item text="消息" icon="chat" badge="3"></u-tabbar-item> <u-tabbar-item text=""> <image style="width: 80rpx;height: 80rpx;" slot="active-icon" src="../static/wallet.png"></image> <image style="width: 80rpx;height: 80rpx;" slot="inactive-icon" src="../static/wallet.png"></image> </u-tabbar-item> <u-tabbar-item text="设置" icon="setting"></u-tabbar-item> </u-tabbar> </template> <script> export default { props: { tab: { type: Number, require: true }, }, data() { return { list: ["/pages/message/index", '/pages/home/index', "/pages/set/index"] } }, methods: { changeTab(name) { console.log(88, name) uni.reLaunch({ url: this.list[name] }) }, } } </script> <style scoped lang="scss"> .status_bar { height: var(--status-bar-height); width: 100%; } </style>
import tabbar from './components/tabbar.vue'
Vue.component('tabbar', tabbar)
<!-- 自定义底部-->
<tabbar :tab="1"></tabbar>
"tabBar": { "color": "#cccccc", "selectedColor": "#E84118", "borderStyle": "black", "backgroundColor": "#ffffff", "list": [{ "pagePath": "pages/home/index", "iconPath": "static/tabbar/1.png", "selectedIconPath": "static/tabbar/1-1.png", "text": "首页" }, { "pagePath": "pages/classify/index", "iconPath": "static/tabbar/2.png", "selectedIconPath": "static/tabbar/2-2.png", "text": "分类" }, { "pagePath": "pages/cart/index", "iconPath": "static/tabbar/3.png", "selectedIconPath": "static/tabbar/3-3.png", "text": "购物车" }, { "pagePath": "pages/my/index", "iconPath": "static/tabbar/4.png", "selectedIconPath": "static/tabbar/4-4.png", "text": "我的" }], // 中间按钮 "midButton": { "pagePath": "pages/my/index", "width": "60px", "height": "45px", "text": "", "iconPath": "static/wallet.png", "iconWidth": "40px" } }
onLaunch: function() {
console.log('App Launch')
uni.onTabBarMidButtonTap(() => {
uni.navigateTo({
url: '/pages/home/list',
});
})
},
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。