perf(scrollbar): scrollbar update when slot changed (#2322)

re #2293
This commit is contained in:
kooriookami 2021-06-25 17:10:55 +08:00 committed by GitHub
parent 93e50e147b
commit 87a23bbbbb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -28,7 +28,7 @@
<script lang="ts">
import { addResizeListener, removeResizeListener } from '@element-plus/utils/resize-event'
import { addUnit, isArray, isString, toObject } from '@element-plus/utils/util'
import { computed, defineComponent, nextTick, onBeforeUnmount, onMounted, provide, ref } from 'vue'
import { computed, defineComponent, nextTick, onBeforeUnmount, onMounted, provide, ref, watch } from 'vue'
import Bar from './bar.vue'
import type { CSSProperties, PropType } from 'vue'
@ -71,7 +71,7 @@ export default defineComponent({
},
},
emits: ['scroll'],
setup(props, { emit }) {
setup(props, { slots, emit }) {
const sizeWidth = ref('0')
const sizeHeight = ref('0')
const moveX = ref(0)
@ -117,6 +117,10 @@ export default defineComponent({
return style
})
watch(() => slots.default?.(), () => {
nextTick(update)
})
onMounted(() => {
if (!props.native) {
nextTick(update)