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 添加网站,将物理路径 ...
随机推荐
- Nginx+PHP(FastCGI)高性能服务器加载redis+memcache模块
1)Nginx+FastCGI安装配置: yum install openssl openssl-devel pcre-devel pcre zlib zlib-devel –y #下载Nginx源 ...
- 在使用pandas 0.23.4对日期进行分组排序时报错
date_df["rank_num"] = date_df.groupby("issuer_id").report_date.agg("rank&qu ...
- Source Insight快捷键
常用使用技巧 按住"ctrl", 再用鼠标指向某个变量(或函数),点击一下,就能进入这个变量(或函数)的定义. 快捷键 "Alt + F12",可以让显示界面中 ...
- matplotlib中的imshow()
import matplotlib.pyplot as plt plt.imshow(x,cmap) x表示要显示的图片变量,cmap为颜色图谱,默认为RGB(A)颜色空间,也可以指定,gray是灰度 ...
- poj2185(kmp算法next数组求最小循环节,思维)
题目链接:https://vjudge.net/problem/POJ-2185 题意:给定由大写字母组成的r×c矩阵,求最小子矩阵使得该子矩阵能组成这个大矩阵,但并不要求小矩阵刚好组成大矩阵,即边界 ...
- 5年经验Java程序员面试20天
写在前面 今天分享的是一位5年工作经验的Java工程师在帝都的面试经验总结,看看这些互联网公司都爱问些什么题,希望对大家的面试有指导意义. 从事Java开发也有5年经验了,4月初自己的开启面试经历 ...
- 纯C++实现操作配置文件(告别跨平台问题)
CConfig.h #ifndef _CCONFIG_H #define _CCONFIG_H #include <iostream> #include <string> #i ...
- LC 21. Merge Two Sorted Lists
题目描述 Merge two sorted linked lists and return it as a new list. The new list should be made by splic ...
- k8s-部署策略
在Kubernetes中有几种不同的方式发布应用,所以为了让应用在升级期间依然平稳提供服务,选择一个正确的发布策略就非常重要了. 选择正确的部署策略是要依赖于我们的业务需求的,下面我们列出了一些可能会 ...
- mysql 查询字段为空显示默认值
IFNULL() 函数用于判断第一个表达式是否为 NULL,如果为 NULL 则返回第二个参数的值,如果不为 NULL 则返回第一个参数的值. IFNULL() 函数语法格式为: IFNULL(exp ...