时间:2023-01-24 10:49:29 | 栏目:vue | 点击:次
vue-admin-template\src\layout\components\TagsView 文件夹
vue-admin-template\src\store\modules\tagsView.js
#vue-admin-template\static 文件夹
#vue-admin-template\src\lang 文件夹
#vue-admin-template\src\utils\i18n.js
AppMain.vue文件,新增以下内容:
<template> <section class="app-main"> <transition name="fade-transform" mode="out-in"> <!-- <router-view :key="key" />--> <keep-alive :include="cachedViews"> <router-view></router-view> </keep-alive> </transition> </section> </template>
export default { name: 'AppMain', computed: { cachedViews() { return this.$store.state.tagsView.cachedViews }/*, key() { return this.$route.path }*/ } }
<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>
新增如下行:
export { default as TagsView } from './TagsView'
<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 /> </div> <tags-view /> <!-- 此处增加tag--> <app-main /> </div> </div> </template>
import { Navbar, Sidebar, AppMain, TagsView } from './components'
components: { Navbar, Sidebar, AppMain, TagsView },
增加:
visitedViews: state => state.tagsView.visitedViews, cachedViews: state => state.tagsView.cachedViews,
import tagsView from './modules/tagsView'
const store = new Vuex.Store({ modules: { app, permission, settings, tagsView, user }, getters })
import i18n from './lang' // Internationalization
new Vue({ el: '#app', router, store, i18n, render: h => h(App) })
tagsView: true,
const { showSettings, tagsView, fixedHeader, sidebarLogo } = defaultSettings const state = { showSettings: showSettings, tagsView: tagsView, fixedHeader: fixedHeader, sidebarLogo: sidebarLogo }
1、删除vue-admin-template\src\layout\components\TagsView\index.vue中routes方法
(因为没有用到权限校验)
2、遍历标签时可能报错