1,在components新建commnn目录,然后再新建nav目录,在此目录下新建nav-bottom.vue文件和nav-item.vue文件

2,nav-bottom.vue中的内容:

    

 <template>
<div>
<div class="nav">
<slot></slot> //插槽
</div>
</div>
</template> <script>
export default {
name: "nav-bottom"
}
</script> <style scoped>
.nav {
display: flex;
position: fixed;
bottom: 0;
left: 0;
right: 0;
background-color: #7b7b7b;
height: 49px;
text-align: center;
}
</style>

3,Nav-item代码:

  

<template>
<div class="nav-item" :class="{isactive:isactive}">
<div @click="change">
<slot name="font-image"></slot> <--!显示字体图片-->
<slot name="font"></slot> <--!显示文字-->
</div>
</div>
</template> <script>
export default {
name: "nav-item",
props: {
path :String // 传递路径
},
computed: {
isactive () {
return this.$route.path.indexOf(this.path) !== -1
}
},
methods: {
change () {
if (this.isactive===false) {
this.$router.push(this.path)
} }
}
}
</script> <style scoped>
.nav-item {
flex: 1;
}
.isactive {
color: red;
}
</style>

4,设置导航下的每个字路由页面:

  shopping  此目录下创建对应的vue文件

  profile   此目录下创建对应的vue文件

  homepage  此目录下创建对应的vue文件
  classify   此目录下创建对应的vue文件

5,设置路由:

import Router from 'vue-router'
import Vue from 'vue' const home = () => import('../components/homepage/Home_msg')
const classify = () => import('../components/classify/Classify')
const shopping = () => import('../components/shopping/Shopping')
const profile = () => import('../components/profile/Profile') Vue.use(Router)
const routes = [
{
path: '',
redirect: '/home'
},
{
path:'/profile',
component: profile
},
{
path:'/classify',
component: classify
},
{
path:'/shopping',
component: shopping
},
{
path:'/home',
component: home
}
]
const router = new Router({
routes,
mode: 'history'
});
export default router

6,抽离组件新建navgation.vue:

 <template>
<div class="aaa">
<nav-item path="home" colorstyle="blue">
<span class="iconfont" slot="font-image"></span>
<div slot="font">首页</div>
</nav-item> <nav-item path="classify" colorstyle="green">
<span class="iconfont" slot="font-image"></span>
<div slot="font">分类</div>
</nav-item> <nav-item path="shopping" colorstyle="hotpink">
<span class="iconfont" slot="font-image"></span>
<div slot="font">购物车</div>
</nav-item> <nav-item path="profile">
<span class="iconfont" slot="font-image"></span>
<div slot="font">我的</div>
</nav-item>
</div>
</template> <script>
import navItem from "./nav-item"
export default {
name: "navgative",
components: {
navItem
}
}
</script> <style scoped>
@import "../assets/images/style.css"; @font-face {font-family: 'iconfont';
src: url('../assets/images/fonts/icomoon.eot');
src: url('../assets/images/fonts/icomoon.eot?#iefix') format('embedded-opentype'),
url('../assets/images/fonts/icomoon.woff') format('woff'),
url('../assets/images/fonts/icomoon.ttf') format('truetype'),
url('../assets/images/fonts/icomoon.svg#iconfont') format('svg');
}
.iconfont{
font-family:"iconfont" !important;
font-size:16px;font-style:normal;
-webkit-font-smoothing: antialiased;
-webkit-text-stroke-width: 0.2px;
-moz-osx-font-smoothing: grayscale;
/*vertical-align: middle;*/
}
.aaa {
display: flex;
position: fixed;
bottom: 0;
left: 0;
right: 0;
}
</style>

navgation.vue

7,app.vue引入组件:

  

<template>
<div id="app">
<router-view></router-view>
<navBottom>
<navgative></navgative>
</navBottom>
</div>
</template> <script>
import navBottom from './components/nav-bottom'
import navgative from './components/navgative'
export default {
name: 'app',
components: {
navBottom,
navgative
}
}
</script> <style> </style>

app.vue

8,npm run serve 运行

vue导航栏制作的更多相关文章

  1. jquery侧边折叠导航栏制作,两行代码搞定

    jquery侧边折叠导航栏制作,两行代码搞定 //CSS*{margin: 0;padding: 0} ul{list-style: none} .menu li ul{display: none} ...

  2. Flutter实战视频-移动电商-03.底部导航栏制作

    03.底部导航栏制作 material是谷歌退出的 还有另外的一种:cupertino是IOS的风格 我们底部的导航栏,静态的widget是不合适的,这垃圾我们用到动态的widget 这重新改成动态的 ...

  3. Flutter实例一--底部规则导航栏制作

    先来看看制作效果: 前置知识--StatefulWidget  StatefulWidget具有可变状态(state)的窗口组件(widget).使用时要根据变化状态,调整State值, 能够快速初始 ...

  4. Vue导航栏在特定的页面不显示~

    最近写vue项目遇到一些问题,我把导航栏组件放在了app.vue中,让他在每个页面都能显示了,但遇到了一个问题,在登录以及注册页面导航栏是不合理不允许存在的 解决方法: 公共模块的内容可以放在App. ...

  5. PHP全栈开发(八):CSS Ⅹ 导航栏制作

    学习了这么久的CSS,我们现在也可以小试牛刀一下了,我们使用我们学会的CSS知识来制作一个导航栏. 我们都知道,在现代的导航栏里面,最普遍的就是使用无序列表来制作导航栏. 我们可以使用如下代码来制作一 ...

  6. 03-Flutter移动电商实战-底部导航栏制作

    1.cupertino_IOS风格介绍 在Flutter里是有两种内置风格的: material风格: Material Design 是由 Google 推出的全新设计语言,这种设计语言是为手机.平 ...

  7. Flutter移动电商实战 --(3)底部导航栏制作

    1.cupertino_IOS风格介绍 在Flutter里是有两种内置风格的: material风格: Material Design 是由 Google 推出的全新设计语言,这种设计语言是为手机.平 ...

  8. vue导航栏实时获取URL设置当前样式,刷新也存在!

    很low 别喷, template代码: <div class="tab-itme"> <ul @click="clickit()"> ...

  9. vue 导航栏切换

    <template> <footer class="menu"> <router-link to="/" class=" ...

随机推荐

  1. RabbitMQ学习之:(二)介绍 (转贴+我的评论)

    转自:http://lostechies.com/derekgreer/2012/03/05/rabbitmq-for-windows-introduction/ RabbitMQ for Windo ...

  2. Python3.x运行Python2.x代码报错 syntax error "Missing parentheses in call to 'print'

    #另外一种错误 SyntaxError: Missing parentheses in call to 'print'. Did you mean print( 查看代码,格式如下: print &q ...

  3. C#中?的相关使用

    C#中?的相关使用 今天看了几篇博客,学习了一下与?相关的使用,大致分为一下几种: 1. 可空类型 看标题就能够很好的理解这个概念:可以为空的类型.而在C#中可以为空也就是null的类型,都是引用类型 ...

  4. 第12课.经典问题解析(const;指针和引用)

    问题1:const什么时候为只读变量?什么时候是常量? const常量的判别准则: a.只有用字面量初始化的const常量才会进入符号表(直接初始化过的const为常量) b.被使用其他变量初始化的c ...

  5. prometheus 监控的目标 - nginx - apache

    1.jvm类型 8563的grafanadashboard: gc时间,使用的现场,加载的类数 2.apache , nginx 用户连接状态,waiting数量 (使用nginx_status) c ...

  6. 在docker容器下安装airflow

    本人的环境是基于centos7下来安装的 一.安装docker  下载docker安装包,下载地址:https://download.docker.com/linux/static/stable/x8 ...

  7. SQLServer学习之表的操作

    SQLServer学习之表的操作 关系数据库通常包含多个表.数据库实际上是表的集合,数据库的数据或者信息都是存储在表中的.表是对数据进行存储和操作的一种逻辑结构,每一个表都代表一个对用户意义的对象. ...

  8. windows下安装和配置SNMP

    window snmp服务开启及测试 转自:https://blog.csdn.net/qq_33314107/article/details/80031446 一 安装 二 开启服务 Linux下安 ...

  9. linux用户和组 之 用户管理

    一. linux 用户和组的基本介绍 1.linux下 有三种用户: 1. root: 权限最大的. 2. 系统用户: UID小于1000的.系统服务管理用户,一般是不允许登录系统的.(比如mysql ...

  10. Zero Array---思维题

    链接        submit B. Zero Array time limit per test 1 second memory limit per test 256 megabytes inpu ...