- 把 vue-element-admin\src\layout\components 下的 TagsView 文件夹 复制到 vue-admin-template 对应的目录
2.把 vue-element-admin\src\store\modules 下的 tagsView.js 复制到vue-admin-template 对应的目录
- 修改 src\store\index.js
import Vue from 'vue'
import Vuex from 'vuex'
import getters from './getters'
import app from './modules/app'
import settings from './modules/settings'
import user from './modules/user'
import tagsView from './modules/tagsView' // 新增
Vue.use(Vuex)
const store = new Vuex.Store({
modules: {
app,
settings,
user,
tagsView // 新增
},
getters
})
export default store
- 修改 src\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
- 修改 src\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>
// 新增 TagsView
import { Navbar, Sidebar, AppMain, TagsView } from './components'
import ResizeMixin from './mixin/ResizeHandler'
export default {
name: 'Layout',
components: {
Navbar,
Sidebar,
AppMain,
TagsView // 新增
},
- 修改 src\layout\components\index.js
export { default as Navbar } from './Navbar'
export { default as Sidebar } from './Sidebar'
export { default as AppMain } from './AppMain'
export { default as TagsView } from './TagsView' // 新增