圆月山庄资源网 Design By www.vgjia.com

vue-element-admin有关快捷导航说明

1、添加标签
@/layout/components/AppMain.vue添加:

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

2、复制admin项目中的文件
@/layout/components/TagsView
@/store/modules/tagsView.js
到template对应的目录下
3、修改文件
@store/getters.js

const getters = {
 sidebar: state => state.app.sidebar,
 device: state => state.app.device,
 token: state => state.user.token,
 avatar: state => state.user.avatar,
 name: state => state.user.name,
 visitedviews: state => state.tagsview.visitedviews //新增
}
export default getters

@store/index.js

import tagsView from './modules/tagsView' //新增

Vue.use(Vuex)

const store = new Vuex.Store({
 modules: {
  app,
  settings,
  user,
  tagsView  //新增
 },
 getters
})

export default store 

@\layout\index.vue

<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 />  <!-- 新增 -->
   </div>
   <app-main />
  </div>
 </div>
</template>

<script>
import { Navbar, Sidebar, AppMain,TagsView } from './components'  //新增

@layout\components\index.js

export { default as TagsView } from './TagsView' // 新增

Affix 固钉
当在声明路由是 添加了 Affix 属性,则当前tag会被固定在 tags-view中(不可被删除)。

vue-admin-template配置快捷导航的代码(标签导航栏)

{
  path: '/',
  component: Layout,
  redirect: '/dashboard',
  children: [
   {
    path: 'dashboard',
    component: () => import('@/views/dashboard/index'),
    name: 'dashboard',
    meta: { title: 'dashboard', icon: 'dashboard', affix: true }
   }
  ]
 },

总结

标签:
vue-admin-template标签导航栏,vue-admin-template导航

圆月山庄资源网 Design By www.vgjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
圆月山庄资源网 Design By www.vgjia.com