cmdb/cmdb-ui/src/layouts/RouteView.vue

33 lines
789 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<script>
export default {
name: 'RouteView',
props: {
keepAlive: {
type: Boolean,
default: true
}
},
data () {
return {}
},
render () {
const { $route: { meta }, $store: { getters } } = this
const inKeep = (
<keep-alive>
<router-view />
</keep-alive>
)
const notKeep = (
<router-view />
)
// 这里增加了 multiTab 的判断当开启了 multiTab
// 应当全部组件皆缓存否则会导致切换页面后页面还原成原始状态
// 若确实不需要可改为 return meta.keepAlive ? inKeep : notKeep
if (!getters.multiTab && !meta.keepAlive) {
return notKeep
}
return this.keepAlive || getters.multiTab || meta.keepAlive ? inKeep : notKeep
}
}
</script>