1 、修改浏览器标签名称:

修改浏览器标签名称在文件:\src\settings.js

 
image.png

2 、修改固定头部Header和侧边栏 Logo:

 
image.png

1)侧边栏文件在:\src\layout\components\Sidebar\index.vue, Sidebar组件中

 
image.png

2)修改侧边栏Log和标题在文件:src\layout\components\Sidebar\Logo.vue

 
image.png

3) 控制showLogo字段在文件 \src\settings.js中 【需要修改这个文件】

fixedHeader:true ==>为true则固定头部,为false则滚动,
sidebarLogo: true ==>为true则显示侧边栏logo,为false则隐藏

module.exports = {
title: 'Vue Admin Template', /**
* @type {boolean} true | false
* @description Whether fix the header
*/
fixedHeader: true, /**
* @type {boolean} true | false
* @description Whether show the logo in sidebar
*/
sidebarLogo: true
}

注意:固定头部除了需要改变fixedHeader:true 属性值外,还需要在\src\layout\components\AppMain.vue添加样式,内边距增高

 
image.png

样式代码

<style lang="scss" scoped>
.app-main {
/*50 = navbar */
min-height: calc(100vh - 50px);
width: 100%;
position: relative;
overflow: hidden;
}
.fixed-header+.app-main {
padding-top: 50px;
} .hasTagsView {
.app-main {
/* 84 = navbar + tags-view = 50 + 34 */
min-height: calc(100vh - 84px);
} .fixed-header+.app-main {
padding-top: 84px;
}
}
</style> <style lang="scss">
// fix css style bug in open el-dialog
.el-popup-parent--hidden {
.fixed-header {
padding-right: 15px;
}
}
</style>
 

3 、添加标签导航栏

文档见:https://panjiachen.github.io/vue-element-admin-site/zh/guide/essentials/tags-view.html

  1. 在setting.js中设置变量tagsView为true,控制tagView是否显示
    文件路径:src\settings.js
 /**
* @type {boolean} true | false
* @description Whether show the logo in sidebar
*/
tagsView: true,
  1. 通过store - setting.js文件控制变量 tagsView
    文件路径:src\store\modules\settings.js
    添加引入变量
const { showSettings, tagsView, fixedHeader, sidebarLogo } = defaultSettings

const state = {
showSettings: showSettings,
fixedHeader: fixedHeader, // 控制是否固定导航
sidebarLogo: sidebarLogo, // 控制头部logo是否显示
tagsView: tagsView // 控制tagsView导航标签栏是否显示
}

3)此步骤可忽略
在store-index.js中暴露settings
文件路径:src\store\index.js

import Vue from 'vue'
import Vuex from 'vuex'
import settings from './modules/settings' Vue.use(Vuex) const store = new Vuex.Store({
modules: {
settings
},
getters
}) export default store

4)拷贝组件tagViews
至文件路径:src\layout\components\TagsView\index.vue

 
image.png

若是无权限路由则修改文件:src\layout\components\TagsView\index.vue里代码,因为admin版本是权限路由,获取路由方式不一样,代码return this.$router.options.routes

 
image.png

5)添加拷贝状态管理文件 store

 
image.png

5.1)拷贝此文件
\src\store\modules\tagsView.js
5.2)在getter.js中添加抛出字段
文件路径:src\store\getters.js

visitedViews: state => state.tagsView.visitedViews,
cachedViews: state => state.tagsView.cachedViews,
image.png

5.3) 引入tagView文件
文件路径:\src\store\index.js

 
image.png
 
import Vue from 'vue'
import Vuex from 'vuex'
import tagsView from './modules/tagsView' Vue.use(Vuex) const store = new Vuex.Store({
modules: {
tagsView
},
getters
}) export default store
 

以上为引入,下面开始使用

6) 在layout - component - index.js文件中添加 引入tagViews组件
文件路径:src\layout\components\index.js

export { default as TagsView } from './TagsView/index.vue'
7)添加keep-alive缓存路由

文件路径:@/layout/components/AppMain.vue

<section class="app-main">
<transition name="fade-transform" mode="out-in">
<keep-alive :include="cachedViews">
<router-view :key="key" />
</keep-alive>
</transition>
</section>

修改js文件

computed: {
cachedViews() {
return this.$store.state.tagsView.cachedViews
},
key() {
console.log(this.$route.path)
return this.$route.path
}
}

8) 修改index.js文件
文件路径:\src\layout\components\index.js

 
image.png
export { default as TagsView } from './TagsView/index.vue'
9) 修改layout - index.vue文件(控制头部是否固定、tagsview导航标签

文件路径:src\layout\index.vue

 
image.png
<template>
<div :class="classObj" class="app-wrapper">
<div v-if="device==='mobile'&&sidebar.opened" class="drawer-bg" @click="handleClickOutside" />
<sidebar class="sidebar-container" />
<div class="main-container">
<div :class="{'fixed-header':fixedHeader}">
<navbar />
<tags-view v-if="needTagsView" />
</div>
<app-main />
</div>
</div>
</template>
import { Navbar, Sidebar, AppMain, TagsView } from './components'
import ResizeMixin from './mixin/ResizeHandler' export default {
name: 'Layout',
components: {
Navbar,
Sidebar,
AppMain,
TagsView
},
mixins: [ResizeMixin],
computed: {
needTagsView() {
console.log(this.$store.state.settings.tagsView)
return this.$store.state.settings.tagsView
// return true
},
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'
}
}
},
  1. 修改原有的dashboard为home(路由里的名称及跳转路径)
    文件路径:src\router\index.js
    注意:当在声明路由是 添加了 Affix 属性,则当前tag会被固定在 tags-view中(不可被删除)。
    添加:affix: true

     
    image.png

10)修改文件dashboard为home
文件路径:tests\unit\components\Breadcrumb.spec.js

最重要的一点:自己编写的vue文件里面的name一定要和router/index.js里面的name一致,否则缓存不会生效

参考资料:https://www.jianshu.com/p/cff91fcfe861

vue element Admin - 修改浏览器标签名 + 添加tagView标签 +固定导航头部 + 添加侧边栏Logo的更多相关文章

  1. vue 修改浏览器标题

    主要思路: 1.可以从路由获取当前页面的标题,再通过document.title设值,或者在最外层的index.html页面添加<title>标签 import router from ' ...

  2. 新书上线:《Spring Boot+Spring Cloud+Vue+Element项目实战:手把手教你开发权限管理系统》,欢迎大家买回去垫椅子垫桌脚

    新书上线 大家好,笔者的新书<Spring Boot+Spring Cloud+Vue+Element项目实战:手把手教你开发权限管理系统>已上线,此书内容充实.材质优良,乃家中必备垫桌脚 ...

  3. Vue+Element实现网页版个人简历系统

    这篇文章介绍一个使用Vue+Element实现的个人简历系统,主要用到的技术有:vue.element.css3.css定位. 作者在window10进行开发,目前只在chrome上进行过测试,没有大 ...

  4. 循序渐进VUE+Element 前端应用开发(17)--- 菜单资源管理

    在权限管理系统中,菜单也属于权限控制的一个资源,应该直接应用于角色,和权限功能点一样,属于角色控制的一环.不同角色用户,登录系统后,出现的系统菜单是不同的.在VUE+Element 前端中,我们菜单结 ...

  5. Vue + Element UI 实现权限管理系统 前端篇(十):动态加载菜单

    动态加载菜单 之前我们的导航树都是写死在页面里的,而实际应用中是需要从后台服务器获取菜单数据之后动态生成的. 我们在这里就用上一篇准备好的数据格式Mock出模拟数据,然后动态生成我们的导航菜单. 接口 ...

  6. Vue + Element UI 实现权限管理系统(动态加载菜单)

    动态加载菜单 之前我们的导航树都是写死在页面里的,而实际应用中是需要从后台服务器获取菜单数据之后动态生成的. 我们在这里就用上一篇准备好的数据格式Mock出模拟数据,然后动态生成我们的导航菜单. 接口 ...

  7. vue+element 实现商品sku效果

    在网上搜索了很久,没有发现合适sku编辑的文章,只能自己写一个vue+element 的sku编辑功能.实现的效果如下图 除成本.售价.库存.货号这几个写死的属性外,可自行添加/删除商品属性,自行添加 ...

  8. Vue Element使用第三库icon图标

    一:引入单设图标 1.打开 阿里icon,注册 >登录>图标管理>我的项目 2.新建项目 返回阿里icon首页,点进去你想要的icon库,因为没有批量导入购物车,所以一般情况下需要一 ...

  9. 循序渐进VUE+Element 前端应用开发(1)--- 开发环境的准备工作

    之前一直采用VS进行各种前端后端的开发,随着项目的需要,正逐步融合纯前端的开发模式,开始主要选型为Vue + Element 进行BS前端的开发,后续会进一步整合Vue + AntDesign的界面套 ...

随机推荐

  1. ModuleNotFoundError: No module named 'phkit.pinyin'

    1 产生背景 在mac系统本地使用正常,在linux系统上phkit包缺少相应的python文件 2 解决方案 自己想出来,手动上传本地相关python代码到linux服务器 3 解决过程 首先通过项 ...

  2. 附002.Nginx代理相关模块解析

    一 ngx_http_proxy_module模块 1.1 proxy_pass配置 proxy_pass URL; Context: location, if in location, limit_ ...

  3. React Native 控制一个component的显示隐藏

      // 首先在constructor里:   this.state = { visible: false }   // 然后在点击事件设置:   this.setState({ visible: t ...

  4. APP自动化 -- 框架

    一.框架源码 https://github.com/jiangnan27/Autotest_APP_Open 二.框架环境 python3 + appium1.15.3 + pytest5.3.5 三 ...

  5. 推荐一款技术人必备的接口测试神器:Apifox

    1. 背景 作为互联网行业技术从业者,接口调试是必不可少的一项技能,通常我们都会选择使用 Postman 这类工具来进行接口调试,在接口调试方面 Postman 做的确实非常出色.当然除了Postma ...

  6. 高度塌陷与BFC

    高度塌陷的产生条件 子元素浮动,脱离文档流 子元素绝对定位或固定定位,脱离文档流 定位产生的高度塌陷只能通过加固定高度或更换其他方案解决塌陷,本文主要讨论浮动产生塌陷的解决方法. 高度塌陷的解决方法 ...

  7. 本地建立mysql服务器

    这里可以学到 : 搭建一个mysql的后台服务器,构建自己的本地数据库表,可以满足一些自己学习增删改查的简单需求   1.打开mysql官网 https://www.mysql.com/downloa ...

  8. 企业权限管理(SSM整合)(总结)

    学于黑马程序员和传智播客联合做的教学项目 感谢 黑马程序员官网 传智播客官网 个人根据教程的每天的工作进度的代码和资料 密码:cti5 b站在线视频 微信搜索"艺术行者",关注并回 ...

  9. 十进制转换为其他进制(不使用format)

    base = [str(x) for x in range(10)] + [chr(x) for x in range(ord('A'), ord('A') + 6)] # ['0', '1', '2 ...

  10. MySQL在同一个表上,删除查询出来的结果

    背景 有一个程序员员工表(code_user),包含用户id.姓名.掌握的语言. 表数据如下: +---------+-----------+----------+ | user_id | user_ ...