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. Android View的加载流程

    什么是Activity? Activity是 用户操作的可视化界面:它为用户提供了一个放置视图和交互操作的窗口.采用setContentView的方法提供.因此,可以理解Activity.Window ...

  2. Nginx优化之服务性能优化

    优化Nginx服务的worker进程个数 修改nginx主配置文件 worker_processes 1; #指定了Nginx要开启的进程数,结尾数字就是进程个数 Nginx有Master进程和wor ...

  3. js对象和jQuery对象的区别

    (1)js对象的三种基本定位方式 (A)通过ID属性:document.getElementById() (B)通过NAME属性:document.getElementsByName() (C)通过标 ...

  4. Hibernate3核心API使用

    public static void main(String[] args) throws Exception{ // 1. 加载默认的hibernate.cfg.xml的配置文件 Configura ...

  5. 九十八:CMS系统之登录页面CSRF保护和修改密码页面

    加上CSRF防御 修改密码页面 视图 class ResetPwd(views.MethodView): decorators = [login_required] # 校验登录状态 def get( ...

  6. WampServer 下载以及安装问题 以及配置远程连接MYSQL

    WampServer 3.0 下载: http://dl.pconline.com.cn/download/52877-1.html 碰到的问题DDL无法添加,解决方法:MSVCR110.DLL fo ...

  7. jackson对Exception类型对象的序列化与反序列化

    发现问题 今天在调试系统错误通知的时候遇到了一个问题.我们在系统异常时候要通过队列系统发送各种通知到团队内部成员. 因此我写了一个通用接口.接口中有传递Exception对象到队列中,再由队列消费者解 ...

  8. 并查集 --以cogs259为例

    题目链接:http://cogs.pro:8081/cogs/problem/problem.php?pid=pySmxSVgP [问题描述]     或许你并不知道,你的某个朋友是你的亲戚.他可能是 ...

  9. windows下的句柄利用

    什么是句柄 维基百科:在程序设计中,句柄(handle)是Windows操作系统用来标识被应用程序所建立或使用的对象的整数.其本质相当于带有引用计数的智能指针.当一个应用程序要引用其他系统(如数据库. ...

  10. Prefix to Infix Conversion

    Infix : An expression is called the Infix expression if the operator appears in between the operands ...