perf(components): avoid unnecessary tab switch rerender (#4513)

Co-authored-by: 周毓杰 <xiake@xiaohongshu.com>
This commit is contained in:
周毓杰 (Oliver Zhou) 2021-11-24 13:55:00 +08:00 committed by GitHub
parent b853b7a9ff
commit adc85619e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -22,6 +22,7 @@ import {
markRaw,
reactive,
} from 'vue'
import { eagerComputed } from '@vueuse/core'
import { tabsRootContextKey } from '@element-plus/tokens'
import { throwError } from '@element-plus/utils/error'
import { tabPaneProps } from './tab-pane'
@ -39,11 +40,11 @@ export default defineComponent({
const index = ref<string>()
const loaded = ref(false)
const isClosable = computed(() => props.closable || tabsRoot.props.closable)
const active = computed(
const active = eagerComputed(
() => tabsRoot.currentName.value === (props.name || index.value)
)
const paneName = computed(() => props.name || index.value)
const shouldBeRender = computed(
const shouldBeRender = eagerComputed(
() => !props.lazy || loaded.value || active.value
)