123456789101112131415161718192021222324252627 |
- import { defineComponent, KeepAlive } from 'vue'
- import { getFullPathWithoutHash } from '../helper'
- export default defineComponent({
- name: 'CipRouterView',
- props: {
- viewKey: String,
- noViewKey: { type: Boolean, default: undefined },
- cacheList: Array
- },
- setup (props) {
- return () => (
- <router-view>
- {{
- default: ({ Component, route, ...args }) => {
- // TODO: 直接修改name可能导致的问题位置
- if (Component && !props.noViewKey) {
- Component.type.name = getFullPathWithoutHash(route.fullPath)
- }
- return <KeepAlive include={props.cacheList}>
- {Component && <Component key={props.viewKey}/>}
- </KeepAlive>
- }
- }}
- </router-view>
- )
- }
- })
|