1.hover时候出现,总体来说只改了一下两个index.vue,还有route文件

src\layoutTwo\index.vue

<template>
<div class="main_container_webgl">
<!-- <div :class="classObj" class="app-wrapper">
<div v-if="device==='mobile'&&sidebar.opened" class="drawer-bg" @click="handleClickOutside" /> <div >
<div :class="{'fixed-header':fixedHeader}">
</div> -->
<app-main /> <div class="my_menu_hover">
<sidebar />
</div>
</div>
</template> <script>
import {
Navbar,
Sidebar,
AppMain
} from './components'
import ResizeMixin from './mixin/ResizeHandler' export default {
name: 'LayoutTwo',
components: {
Navbar,
Sidebar,
AppMain
},
mixins: [ResizeMixin],
computed: {
sidebar() {
return this.$store.state.app.sidebar
},
device() {
return this.$store.state.app.device
},
fixedHeader() {
return this.$store.state.settings.fixedHeader
},
classObj() {
return {
hideSidebar: !this.sidebar.opened,
openSidebar: this.sidebar.opened,
withoutAnimation: this.sidebar.withoutAnimation,
mobile: this.device === 'mobile'
}
}
},
methods: {
handleClickOutside() {
this.$store.dispatch('app/closeSideBar', {
withoutAnimation: false
})
}
}
}
</script> <style lang="scss" scoped>
@import "~@/styles/mixin.scss";
@import "~@/styles/variables.scss"; // 测试菜单
#app {
.main_container_webgl {
.my_menu_hover {
height: 50px;
width: 100%;
position: fixed;
top: 0;
left: 0;
z-index: 99999;
background: rgba(0, 0, 0, 0); /deep/.my_layout_sidebar_test {
width: 100%;
height: 0px;
line-height: 0px;
overflow: hidden;
background: rgba(0, 0, 0, 0.2);
font-size: 15px;
color: white;
display: flex;
justify-content: space-between; /deep/.my_layout_sidebar_test_li {
display: inline-block;
width: 200px;
height: 100px;
line-height: 100px; .my_font {
text-align: center;
color: white;
} .my_font:hover {
color: #49e0ff;
}
}
}
} .my_menu_hover:hover {
height: 150px;
transition: all .5s linear;
background: rgba(0, 0, 0, 0.5);
border: 1px solid black; /deep/.my_layout_sidebar_test {
height: 100px;
line-height: 100px;
font-size: 20px; /deep/.my_layout_sidebar_test_li {
display: inline-block;
width: 200px;
height: 100px;
line-height: 100px; }
} } }
} // 测试菜单 .app-wrapper {
@include clearfix;
position: relative;
height: 100%;
width: 100%; &.mobile.openSidebar {
position: fixed;
top: 0;
}
} .drawer-bg {
background: #000;
opacity: 0.3;
width: 100%;
top: 0;
height: 100%;
position: absolute;
z-index: 999;
} .fixed-header {
position: fixed;
top: 0;
right: 0;
z-index: 9;
width: calc(100% - #{$sideBarWidth});
transition: width 0.28s;
} .hideSidebar .fixed-header {
width: calc(100% - 54px)
} .mobile .fixed-header {
width: 100%;
}
</style>

src\layoutTwo\components\Sidebar\index.vue

<template>
<ul class="my_layout_sidebar_test">
<li v-for="route in routes" :key="route.path" class="my_layout_sidebar_test_li">
<app-link :to="route.redirect">
<div class="my_font">{{route.meta.title}}</div>
</app-link>
</li>
</ul>
</template> <script>
import {
mapGetters
} from 'vuex';
import AppLink from './Link'
import Logo from './Logo';
import SidebarItem from './SidebarItem';
import variables from '@/styles/variables.scss'; export default {
components: {
SidebarItem,
Logo,AppLink
},
computed: {
...mapGetters(['sidebar']),
routes() {
let arr = this.$router.options.routes.filter(_ => _.hidden === false)
return arr;
},
activeMenu() {
const route = this.$route;
const {
meta,
path
} = route;
// if set path, the sidebar will highlight the path you set
if (meta.activeMenu) {
return meta.activeMenu;
}
return path;
},
showLogo() {
return this.$store.state.settings.sidebarLogo;
},
variables() {
return variables;
},
isCollapse() {
return !this.sidebar.opened;
}
}
};
</script> <style lang="less" scoped> </style>

src\layoutTwo\components\Sidebar\Link.vue


<template>
<!-- eslint-disable vue/require-component-is -->
<component v-bind="linkProps(to)">
<slot />
</component>
</template> <script>
import { isExternal } from '@/utils/validate' export default {
props: {
to: {
type: String,
required: true
}
},
methods: {
linkProps(url) {
if (isExternal(url)) {
return {
is: 'a',
href: url,
target: '_blank',
rel: 'noopener'
}
}
return {
is: 'router-link',
to: url
}
}
}
}
</script>

route

{
path: '/login',
component: () => import('@/views/login/index'),
meta: { title: 'login', icon: 'dashboard' },
hidden: true
},
{
path: '/',
hidden: false,
component: layoutTwo,
redirect: '/dashboard',
meta: { title: '首頁', icon: 'dashboard' },
children: [
{
path: 'dashboard',
name: 'Dashboard',
component: () => import('@/views/FFF/FFF01'),
meta: { title: '首頁', icon: 'dashboard' }
}
]
},
{
path: '/FFFOne',
hidden: false,
component: layoutTwo,
redirect: '/FFFOne/first',
meta: { title: 'FFFOne', icon: 'dashboard' },
children: [
{
path: 'first',
name: 'first',
component: () => import('@/views/FFF/FFF01'),
meta: { title: '首頁', icon: 'dashboard' }
}
]
},

使用vue创建一个吸顶的菜单项--简单版的更多相关文章

  1. Vue开发——实现吸顶效果

    因为项目需求,最近开始转到微信公众号开发,接触到了Vue框架,这个效果的实现虽说是基于Vue框架下实现的,但是同样也可以借鉴到其他地方,原理都是一样的. 进入正题,先看下效果图: 其实js做这个效果还 ...

  2. 用Vue创建一个新的项目

    vue的安装 Vue.js不支持IE8及以下版本.因为Vue.js使用了ECMAScript5特性,IE8显然不能模拟.Vue.js支持所有兼容ECMAScript5的浏览器. 在用Vue.js构建大 ...

  3. 使用Vue创建一个新项目

    1.环境 保证已经安装好了node\npm\vue等工具,将路径设置为想要建立新项目的文件夹路径 2.关于npm与cnpm npm包管理器,是集成在node中的,node环境安装完成,npm包管理器也 ...

  4. ng-alain创建组件添加路由导航菜单项基础步骤详解

    首先呢~ 我们要在需要创建模块的路径例如AAA目录下,在终端打开(就是和在shell窗口打开一样的) 然后 ng g ng-alain:module XXXmodule 好了,创建了一个模块 接下来会 ...

  5. 如何创建一个https的站点(超简单) 以及 IIS7.5绑定Https域名

    1.申请免费1年的ssl证书(传送门:https://common-buy.aliyun.com/?spm=5176.2020520163.cas.29.N0xOPM&commodityCod ...

  6. Elastic: 创建一个 Elastic 邮件警报 - 7.7 发行版

    文章转载自:https://blog.csdn.net/UbuntuTouch/article/details/106185321 总结: 1.elastic 免费版只有发送警报到一个索引或者到Ser ...

  7. 使用vue-cli创建一个vue项目

    安装vue-cli npm install -g @vue/cli 1, 使用vue创建一个项目 vue create luffy 2, 安装所需的插件 npm install vue-router ...

  8. wordpress插件开发从创建一个新的菜单开始

    创建插件的目的 1.我们为什么要创建一个插件? IT界有一个知名的论调叫做不要造重复的轮子,如果有可能的话,你应该尽可能的从现有的网络资源上选择一个已有的插件来使用,而不是重新创造一个.它耗费的精力很 ...

  9. 使用media Queries实现一个响应式的菜单

    Media queries是CSS3引入的一个特性,使用它可以方便的实现各种响应式效果.在这个示例中我们将会使用media queries实现一个响应式的菜单.这个菜单会根据当前浏览器屏幕的大小变化而 ...

随机推荐

  1. 2.pygame快速入门-绘制图像

    介绍 在游戏中能够看到的游戏元素大都是图像 图像文件初始是保存在磁盘上的,如果需要使用,第一步就需要被加载到内存 要在屏幕上看到某一个图像的内容,需要按照三个步骤 使用pygame.image.loa ...

  2. maven 重复依赖不同版本 选择规则

    maven 重复依赖不同版本 选择规则 本篇主要来看看 maven 对于 重复依赖的jar的不同版本时候 它内部的选择规则, 很多时候我们在搭建环境的时候 不注意就会存在依赖冲突等问题 那依赖冲突的时 ...

  3. SpringCloud怎么迈向云原生?

    很多公司由于历史原因,都会有自研的RPC框架. 尤其是在2015-2017期间,Spring Cloud刚刚面世,Dubbo停止维护多年,很多公司在设计自己的RPC框架时,都会基于Spring Clo ...

  4. 八、docker compose容器编排

    一. Docker-Compose 1.1. 什么是Docker Compose Compose 项目是 Docker 官方的开源项目,负责实现 Docker 容器集群的快速编排,开源代码在 http ...

  5. 支持JDK19虚拟线程的web框架,之二:完整开发一个支持虚拟线程的quarkus应用

    欢迎访问我的GitHub 这里分类和汇总了欣宸的全部原创(含配套源码):https://github.com/zq2599/blog_demos 本篇概览 本篇是<支持JDK19虚拟线程的web ...

  6. SpringCloud(九) - Nginx

    1.安装Nginx 1.1 解压上传安装包 解压# nginx-1.16.1.tar.gz # nginx需要一些环境(全部执行,不存在的会执行,存在的会跳过) yum install -y wget ...

  7. 第2-2-4章 常见组件与中台化-常用组件服务介绍-分布式ID-附Snowflake雪花算法的代码实现

    目录 2.3 分布式ID 2.3.1 功能概述 2.3.2 应用场景 2.3.3 使用说明 2.3.4 项目截图 2.3.5 Snowflake雪花算法的代码实现 2.3 分布式ID 2.3.1 功能 ...

  8. 前端学习 linux —— 软件安装(Ubuntu)

    软件安装(Ubuntu) 本篇主要讲解 ubuntu 中软件的安装.apt 的源.内网部署案例(graylog 为例),最后是 python 开发准备. apt 和 rpm 在linux 第一篇我们知 ...

  9. 使用c#的 async/await编写 长时间运行的基于代码的工作流的 持久任务框架

    持久任务框架 (DTF) 是基于async/await 工作流执行框架.工作流的解决方案很多,包括Windows Workflow Foundation,BizTalk,Logic Apps, Wor ...

  10. ssm 乱码

    1.post乱码:在web.xml中增加解决解决post乱码的过滤器 <!--解决POST乱码问题--> <filter> <filter-name>Charact ...