1.在compontents新建文件放入

<template>
<section class="tabBar-wrap">
<article class="tabBar-box">
<ul class="tabBar-nav" v-if="navList.length > 0">
<li
class="item"
v-for="(item, index) in navList"
@click="selectNavItem(index,item.pagePath)"
:key="index"
>
<p class="item-images">
<img
:src="selectNavIndex === index ? item.selectedIconPath : item.iconPath"
alt="iconPath"
>
</p>
<p
:class="selectNavIndex === index ? 'item-text item-text-active' : 'item-text' "
>{{item.text}}</p>
</li>
<li v-if="needButton" style="flex: 3">
<div class="submit-box">
<button
:disabled="!handButton"
@click="bindNavigateTo('../pages/index')"
:class="handButton ? 'submit-box-btn submit-box-btn-active' : 'submit-box-btn' "
>{{ btnText }}</button>
</div>
</li>
</ul>
</article>
</section>
</template>
<script>
export default {
props: ["selectNavIndex", "needButton", "handButton", "btnText"],
data() {
return {
navList: [
{
selectedIconPath: "/static/image/delete.png",
iconPath: "/static/image/delete.png",
pagePath: "../index/main",
text: "首页"
},
{
selectedIconPath: "/static/image/delete.png",
iconPath: "/static/image/delete.png",
pagePath: "../index1/main",
text: "发布"
},
{
selectedIconPath: "/static/image/delete.png",
iconPath: "/static/image/delete.png",
pagePath: "../index2/main",
text: "订单"
}
]
};
},
methods: {
selectNavItem(index, pagePath) {
if (index === this.selectNavIndex) {
return false;
}
console.log(index);
if (index == 0 && this.selectNavIndex == -1) {
this.$emit("fetch-index");
}
this.bindViewTap(pagePath);
},
bindNavigateTo(url) {
wx.navigateTo({
url
});
},
bindViewTap(url) {
let page = getCurrentPages();
console.log(page);
wx.reLaunch({
url
});
}
}
};
</script>
<style lang="less" scoped>
.tabBar-box {
position: fixed;
bottom: 0;
width: 100%;
height: 50px;
border-top: 1px solid #eee;
background-color: #f8f8f8;
}
.tabBar-nav {
width: 100%;
display: flex;
.item {
flex: 1;
text-align: center;
}
.item-text {
color: #666;
font-size: 9px;
transition: 0.24s linear;
}
.item-text-active {
color: #f33f3f;
}
.item-images {
width: 21px;
height: 21px;
margin: 4px auto;
text-align: center;
transition: 0.24s linear;
& img {
display: inline;
}
}
}
.submit-box-btn {
position: relative;
z-index: 999;
width: 85%;
height: 90px;
line-height: 90px;
border-radius: 10px;
color: #404040;
font-size: 36px;
border: none;
background-color: #eee;
text-align: center;
border: 1px solid #eee;
}
.submit-box-btn-active {
color: #fff;
border: none;
border: 1px solid #ff6c00;
background-color: #ff6c00;
}
button {
border: none;
outline: none;
}
</style>
 
2.在终端下输入命令    npm i vue-style-loader less-loader css-loader vue-loader less
 
3.在使用的页面引入文件夹

import vueTabBar from "../../components/vueTabBar.vue";
 
4.

components: {
vueTabBar
}
 
5.

<vueTabBar :selectNavIndex="selectNavIndex"></vueTabBar>
 
data中定义

selectNavIndex:0
 
大功告成!!!!

小程序 mpvue自定义底部导航栏的更多相关文章

  1. uniapp 小程序实现自定义底部导航栏(tarbar)

    在小程序开发中,默认底部导航栏很难满足实际需求,好在官方给出了自定义形式,效果如下: 话不多说,直接上代码 1.组件 custom-tarbar.vue文件 <template> < ...

  2. 微信小程序自定义底部导航栏组件+跳转

    微信小程序本来封装有底部导航栏,但对于想自定义样式和方法的开发者来说,这并不是很好. 参考链接:https://github.com/ljybill/miniprogram-utils/tree/ma ...

  3. 小程序配置单个页面导航栏的属性(微信小程序交流群:604788754)

    配置单个页面导航栏的属性: 就在所要配置页面相对应的json文件中写入以下想要设置的属性: { "navigationBarBackgroundColor": "#fff ...

  4. 初尝微信小程序2-Swiper组件、导航栏标题配置

    swiper 滑块视图容器. 很多网页的首页都会有一个滚动的图片模块,比如天猫超市首页,滚动着很多优惠活动的图片,用来介绍优惠内容,以及供用户点击快速跳转到相应页面. Swiper不仅可以滚动图片,也 ...

  5. 微信小程序之自定义底部弹出框动画

    最近做小程序时,会经常用到各种弹框.直接做显示和隐藏虽然也能达到效果,但是体验性太差,也比较简单粗暴.想要美美地玩,添加点动画还是非常有必要的.下面做一个底部上滑的弹框. wxml <view ...

  6. 自定义底部导航栏(tabBar)

    前言如果大家用过微信提供的tabBar就会发现,他的tabBar有很大的局限性.暂且不说样式局限性了,他提供的app.json配置文件中没有function.这也就意味着使用它提供的这个组件,你只能用 ...

  7. 微信小程序开发之tab导航栏

    实现功能: 点击不同的tab导航,筛选数据 UI:   js: data:{ navbar: ['半月维保', '季度维保', '半年维保',"年度维保"],    //count ...

  8. 微信小程序点击顶部导航栏切换样式

    类似这样的效果 <view class='helpCateList'> <!-- 类别 --> <scroll-view class='scroll-view' scro ...

  9. 微信小程序从零开始开发步骤(三)底部导航栏

    上一章节,我们分享了如何创建一个新的页面和设置页面的标题,这一章我们来聊聊底部导航栏是如何实现的.即点击底部的导航,会实现不同对应页面之间的切换. 我们先来看个我们要实现的底部导航栏的效果图:(三个导 ...

随机推荐

  1. 【转】Webdriver的PageObject改造By 张飞

    Webdriver的PageObject改造 PageObject中提供了一个@FindBy注解,也非常好用,但由于其是一次性全部初始化所有的WebElement,对于当前还不存在于页面上的Eleme ...

  2. 18-matlab知识点复习一

    clc; clear; %% 输出 clc, clear; fprintf('%.19f', pi); fprintf('%d', 110); inf pi disp([1,3,5]) disp('a ...

  3. taro Object(...) is not a function 版本更新后,H5端运行出错

    之前使用taro,版本号1.2.11 会有这样的问题,如下:gitHub找解决的,看到大佬们说更新一下版本就好了,果然更新后,此问题解决OK了. 当然,坑是走不完的,版本也更新挺快的,想着把taro和 ...

  4. tiny4412 --Uboot移植(4) 串口

    开发环境:win10 64位 + VMware12 + Ubuntu14.04 32位 工具链:linaro提供的gcc-linaro-6.1.1-2016.08-x86_64_arm-linux-g ...

  5. 一篇文章搞定百度OCR图片文字识别API

    一篇文章搞定百度OCR图片文字识别API https://www.jianshu.com/p/7905d3b12104

  6. .NET Core PartialView 与 Ajax

    Ajax的核心是XMLHttpRequest对象(XHR),能够以异步方式从服务器获取新数据.开发主要利用Ajax来执行异步刷新和局部视图更新的功能. 而开发常常在前段页面利用JQuery封装的Aja ...

  7. eclipse Filter web.xml 问题解决 异步请求@WebServlet

    <filter> <filter-name>AsynServlete</filter-name> <filter-class>com.kad.app.a ...

  8. js二分算法排序

    var arr = [1,2,3,5,10,15,23,35,67,76,78,89,100];var len = arr.length;for (var i = 1; i < len; i++ ...

  9. tomcat简单使用

    下载解压tomcat[root@localhost]# tar zxf apache-tomcat-8.5.4.tar.gz -C /usr/local/tomcat yum自带JDK,注意区别JRE ...

  10. Isight 命令行运行任务

    说明书参考:https://abaqus-docs.mit.edu/2017/English/DSSIMULIA_Established.htm 不一定对版本.但是大部分还可以. 不对的可以在命令里敲 ...