Caching routes doest work in nested routes ,so providing addCachedView between the concrete route and route with component Layout provides solution
This commit is contained in:
parent
33a93a12b4
commit
0c010d7d3d
|
@ -105,6 +105,10 @@ export default {
|
||||||
addTags() {
|
addTags() {
|
||||||
const { name } = this.$route
|
const { name } = this.$route
|
||||||
if (name) {
|
if (name) {
|
||||||
|
const matchedRoutes = this.$route.matched
|
||||||
|
for (let i = 1; i < matchedRoutes.length - 1; i++) {
|
||||||
|
this.$store.dispatch('tagsView/addCachedView', matchedRoutes[i])
|
||||||
|
}
|
||||||
this.$store.dispatch('tagsView/addView', this.$route)
|
this.$store.dispatch('tagsView/addView', this.$route)
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
@ -135,6 +139,12 @@ export default {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
closeSelectedTag(view) {
|
closeSelectedTag(view) {
|
||||||
|
const matchedRoutes = view.matched
|
||||||
|
for (let i = 1; i < matchedRoutes.length - 1; i++) {
|
||||||
|
this.$store.dispatch('tagsView/delCachedView', matchedRoutes[i]).then(response => {
|
||||||
|
console.log('Deleted cached views')
|
||||||
|
})
|
||||||
|
}
|
||||||
this.$store.dispatch('tagsView/delView', view).then(({ visitedViews }) => {
|
this.$store.dispatch('tagsView/delView', view).then(({ visitedViews }) => {
|
||||||
if (this.isActive(view)) {
|
if (this.isActive(view)) {
|
||||||
this.toLastView(visitedViews, view)
|
this.toLastView(visitedViews, view)
|
||||||
|
|
|
@ -5,3 +5,14 @@
|
||||||
</el-alert>
|
</el-alert>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'Menu1',
|
||||||
|
created() {
|
||||||
|
console.log('Menu-1 created')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
|
@ -5,3 +5,13 @@
|
||||||
</el-alert>
|
</el-alert>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: 'Menu11',
|
||||||
|
created() {
|
||||||
|
console.log('Menu-1-1 created')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue