uni-app之tabBar的自己配置
1.因为产品相关的的权限,需要配置不同的导航,这时候需要自定义导航。分离出来的就是一个小的组件。(tabBar.vue)
此处暂时用的html插入的代码,能粘贴到vue文件即可。
<template>
<view class="tabBar">
<view v-for="(item,index) in tabBar" :key="item.url" class="tabbar_item" :class="{'active':item.url == currentPage}"
@click="navTo(item,index)">
<image v-if="item.url == currentPage" :src="item.imgClick" mode=""></image>
<image v-else :src="item.imgNormal" mode=""></image>
<view class="text">{{item.text}}</view>
</view>
</view>
</template>
<script>
export default {
props: {
currentPage: {
type: String,
default: 'index'
}
},
data() {
return {
tabBar: [{
url: 'information',
text: '消息',
imgNormal:'../../static/images/information.png',
imgClick:'../../static/images/active/information_active.png'
},
{
url: 'officialPartner',
text: '合作商',
imgNormal:'../../static/images/officialPartner.png',
imgClick:'../../static/images/active/offPartner_active.png'
},
{
url: 'stock',
text: '库存',
imgNormal:'../../static/images/stock.png',
imgClick:'../../static/images/active/stock_active.png'
}, {
url: 'product',
text: '产品',
imgNormal:'../../static/images/product.png',
imgClick:'../../static/images/active/product_active.png'
}, {
url: 'mine',
text: '我的',
imgNormal:'../../static/images/mine.png',
imgClick:'../../static/images/active/mine_active.png'
}
],
level:'' };
},mounted(){
let userlevel = uni.getStorageSync('level');
/* console.log(userlevel); */
let _this = this;
if (userlevel== 1) {
_this.tabBar.splice(3, 1);
} else {
_this.tabBar.splice(1,1);
_this.tabBar.splice(1,1);
}
},
created() {
uni.hideTabBar({})
},
computed: { },
methods: {
navTo(item,index) {
let _this = this;
if (item.url !== _this.currentPage) {
var isUrl = `/pages/${item.url}/${item.url}`
const that = this
uni.switchTab({
url: isUrl
})
} else {
/* this.$parent.toTop() */
}
}
}
}
</script>
<style lang="scss" scoped>
//导航栏设置
$isRadius:20upx; //左上右上圆角
$isWidth:100vw; //导航栏宽度
$isBorder:1px solid #eeeeee; //边框 不需要则设为0px
$isBg:white; //背景 // 选中设置
$chooseTextColor:#1b60ac; //选中时字体颜色
$chooseBgColor:white; //选中时背景颜色 transparent为透明 //未选中设置
$normalTextColor:#999; //未选中颜色 .tabBar {
width: $isWidth;
height: 100upx;
position: fixed;
bottom: 10upx;
left: 0;
right: 0;
margin: 0 auto;
z-index: 998;
background-color: $isBg;
color: $normalTextColor;
border-left: $isBorder;
border-top: $isBorder;
border-right: $isBorder;
display: flex;
justify-content: space-around;
border-top-right-radius: $isRadius;
border-top-left-radius: $isRadius;
box-sizing: border-box;
overflow: hidden; .tabbar_item {
width: 25%;
font-size: 12px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center; &.active {
/* border-left: $isBorder;
border-top: $isBorder; */
background: $chooseBgColor;
color: $chooseTextColor;
}
} image {
width: 36upx;
height: 36upx;
margin-left: 5upx;
}
}
</style>
2、页面引入。


uni-app之tabBar的自己配置的更多相关文章
- uni app中使用自定义图标库
项目中难免会用到自定义图标,那在uni app中应该怎么使用呢? 首先, 将图标目录放在static资源目录下: 在main.js中引入就可以全局使用了 import '@/static/icon-o ...
- uni app 零基础小白到项目实战-1
uni-app是一个使用vue.js开发跨平台应用的前端框架. 开发者通过编写vue.js代码,uni-app将其编译到Ios,android,微信小程序等多个平台,保证其正确并达到优秀体验. Uni ...
- 微信小程序app.json文件常用全局配置
小程序根目录下的 app.json 文件用来对微信小程序进行全局配置,决定页面文件的路径.窗口表现.设置网络超时时间.设置多 tab 等. JOSN文件不允许注释,下面为了学习加上注释,粘贴需要的片段 ...
- winform app.config文件的动态配置
获取 获取应用程序exe.config文件中 节点value值 /// <summary> /// 功能: 读取应用程序exe.config文件中 /// appSettings节点下 ...
- 在Web.config或App.config中的添加自定义配置
.Net中的System.Configuration命名空间为我们在web.config或者app.config中自定义配置提供了完美的支持.最近看到一些项目中还在自定义xml文件做程序的配置,所以忍 ...
- 使用ionic与cordova(phonegap)进行轻量级app开发前的环境配置与打包安卓apk过程记录
前言 有人说:"如果你恨一个人,就让ta去接触cordova(phonegap)",这是因为这里面的水很深,坑很多,真让人不是一般地发狂.或许有幸运的人儿基本顺顺利利就配置完环境 ...
- vue.js移动端app实战1:初始配置
本系列将会用vue.js2制作一个移动端的webapp单页面,页面不多,大概在7,8个左右,不过麻雀虽小,五脏俱全,常用的效果如轮播图,下拉刷新,上拉加载,图片懒加载都会用到.css方面也会有一些描述 ...
- 在Web.config或App.config中的添加自定义配置 <转>
.Net中的System.Configuration命名空间为我们在web.config或者app.config中自定义配置提供了完美的支持.最近看到一些项目中还在自定义xml文件做程序的配置 ...
- [.net]手机APP与IIS服务器联调配置
前端时间写过一段时间接口,在后期的时候,出现了一些无法通过查看日志来找出问题所在的bug.于是,将手机APP连接到IIS服务器上进行调试,下面是配置的具体步骤 1. 配置IIS 添加网站,将物理路径 ...
随机推荐
- 遇到引入的JS不起作用
1.js的加载是有先后顺序的,并且不能重复引入,重复引入的只有最后一个起作用 2.在使用ligerUI的时候一定要先引用jQuery再引用ligerUI 3.在使用jQuery时遇到变量名未定义的主要 ...
- boost::bind四种应用场景的例子
普通函数 int f( int a, int b ){return a + b;}boost::bind( f, _1, 9 )( 1 ) 成员函数 struct demo{int f( in ...
- Spring IoC 和 DI 简介(二)
Spring IoC 和 DI 简介 IoC:Inverse of Control(控制反转) 读作“反转控制”,更好理解,不是什么技术,而是一种设计思想,就是将原本在程序中手动创建对象的控制权,交由 ...
- 使用Duilib开发Windows软件(3)——控件的样式
摘抄下 https://www.cnblogs.com/Alberl/p/3344936.html 的一段代码 <?xml version="1.0" encoding=&q ...
- 【全排列+子序列】Color
[题意] 这个题目就是问,是否存在每个人对应每一种颜色,如果存在则输出字典序最小的. 否则输出-1 [题解] 利用next_permutation来构造36种情况.记住最后还需要排序一遍. 然后用子序 ...
- 通过getAdaptiveExtension生成的动态类
通过getAdaptiveExtension生成的动态类 方便调式使用 请放在根目录下
- Solr综合案例深入练习
1. 综合案例 1.1. 需求 使用Solr实现电商网站中商品信息搜索功能,可以根据关键字.分类.价格搜索商品信息,也可以根据价格进行排序,并且实现分页功能. 界面如下: 1.2. 分析 开发人员需要 ...
- [Office 365] Office 365与Visio 2013/2016兼容性测试
Visio Professional 2013 (x64) - (Chinese-Simplified) 详细信息 文件名 cn_visio_professional_20 ...
- (七)装配Bean(1)
针对给接口提供哪一个具体的实现,也就是装配哪一种具体的实现bean,在Spring中提供了多种方式,主要包括3种: 一.隐式的bean发现机制和自动装配(自动化装配bean) 二.在Java类中进行显 ...
- Java InsertionSort
Java InsertionSort /** * <html> * <body> * <P> Copyright 1994-2018 JasonInternatio ...