在一个微信小程序中想要用到两种不同的tabbar样式,需要在app.js中自定义,在页面加载时进行调用。
第一个tabbar
首先有一个模板文件:tabbar.wxml
<template name="tabBar">
<view class="tab-bar" style="color: {
{tabBar.color}}; background: {
{tabBar.backgroundColor}}; {
{tabBar.position=='top'? 'top: 0' : 'bottom: 0'}};">
<block wx:for="{
{tabBar.list}}" wx:key="pagePath">
<navigator hover-class="none" url="{
{item.pagePath}}" open-type="redirect" class="{
{item.clas}}" style="{
{item.active? 'color: '+(item.selectedColor? item.selectedColor : tabBar.selectedColor) : ''}}">
<image src="{
{item.selectedIconPath}}" wx:if="{
{item.active}}" class="img"></image>
<image src="{
{item.iconPath}}" wx:if="{
{!item.active}}" class="img"></image>
<text class="tabbar_text">{
{item.text}}</text>
</navigator>
</block>
<view class="clear"></view>
</view>
</template>
在app.js中自定义如下
这里我的cbl是封装好的请求
const cbl = require('utils/cbl.js');
var usercode=""
App({
onLaunch: function () {
var that=this;
wx.getStorage({
key: 'userinfo',
success: function(res) {
if(res.data){
usercode = res.data.UserCode;
}else{
usercode = ""
}
}
})
},
//第一种底部
editTabBar: function () {