This commit is contained in:
Vergil
2020-02-19 14:33:24 +08:00
parent 6510d0b2ab
commit e3f9dcaa1d
4 changed files with 27 additions and 6 deletions

View File

@@ -1,19 +1,30 @@
<template>
<section class="app-main">
<!-- <router-view :key="key"></router-view> -->
<transition name="fade-transform" mode="out-in">
<!-- or name="fade" -->
<!-- <router-view :key="key"></router-view> -->
<keep-alive>
<router-view/>
<keep-alive id="keepAlive">
<router-view v-if="$route.meta.keepAlive"/>
</keep-alive>
</transition>
<transition name="fade-transform" mode="out-in">
<router-view v-if="!$route.meta.keepAlive"/>
</transition>
</section>
</template>
<script>
import store from '@/store'
export default {
name: 'AppMain',
computed: {
keepAliveList() {
var keepAliveList = ''
store.state.tagsView.cachedViews.map(v => {
keepAliveList = keepAliveList + v + ','
})
console.log(keepAliveList)
return keepAliveList
}
// key() {
// return this.$route.name !== undefined ? this.$route.name + +new Date() : this.$route + +new Date()
// }

View File

@@ -71,6 +71,11 @@ export default {
return false
},
isActive(route) {
console.log(this.contactList)
this.contactList = []
if (!this.$route.meta.keepAlive) {
this.$route.meta.keepAlive = true
}
return route.path === this.$route.path || route.name === this.$route.name
},
addViewTags() {
@@ -101,8 +106,14 @@ export default {
if (this.isActive(view)) {
const latestView = views.slice(-1)[0]
if (latestView) {
if (this.$route.meta.keepAlive) {
this.$route.meta.keepAlive = false
}
this.$router.push(latestView.path)
} else {
if (this.$route.meta.keepAlive) {
this.$route.meta.keepAlive = false
}
this.$router.push('/')
}
}