update 更换树滚动条

This commit is contained in:
2021-05-26 18:09:25 +08:00
parent 249007c237
commit a8ecb30cab
2 changed files with 41 additions and 85 deletions

View File

@@ -1,6 +1,4 @@
import Swiper from 'swiper'
let timer, swiper
let timer
export default {
props: {
@@ -45,28 +43,6 @@ export default {
this.onLoadData()
},
mounted() {
const container = this.$refs.swiper,
scrollBar = container.querySelector('.swiper-scrollbar')
const swiperOptions = {
direction: 'vertical',
slidesPerView: 'auto',
freeMode: true,
scrollbar: {
el: scrollBar,
},
mousewheel: true,
}
swiper = new Swiper(container, swiperOptions)
window.addEventListener('resize', () => {
this.onUpdateSwiper()
})
},
methods: {
renderBreadcrumbItem() {
@@ -114,10 +90,6 @@ export default {
this.expandedKeys = this.list.map(p => p.key)
}
this.data = data
this.$nextTick(() => {
this.onUpdateSwiper()
})
}).finally(() => {
this.loading = false
})
@@ -130,7 +102,6 @@ export default {
onExpand(expandedKeys) {
this.expandedKeys = expandedKeys
this.autoExpandParent = false
this.onUpdateSwiper()
},
onUnexpandAll() {
@@ -150,11 +121,6 @@ export default {
this.searchValue = value
this.expandedKeys = expandedKeys
this.autoExpandParent = true
this.$nextTick(() => {
this.onUpdateSwiper()
})
},
onSelect(selectedKeys) {
@@ -167,14 +133,6 @@ export default {
this.$emit('select', selectedIds)
},
onUpdateSwiper() {
clearTimeout(timer)
timer = setTimeout(() => {
swiper.update()
swiper.update()
}, 300)
},
generateKey(data, level) {
const n = level || [0]
n.push(0)
@@ -267,26 +225,21 @@ export default {
<a-icon type="switcher" onClick={this.onUnexpandAll} />
</a-tooltip>
</div>
<div class="swiper-container" ref="swiper">
<div class="swiper-wrapper">
<div class="swiper-slide">
<a-spin style={{ height: '100%' }} spinning={this.loading}>
<a-icon slot="indicator" type="loading" spin />
{
!this.loading && !this.list.length ?
<a-empty description={false} class="ant-list-empty-text">
<template slot="image">
<a-icon class="h3 mt-xl mb-md" type="smile" />
<p>暂无数据</p>
</template>
</a-empty>
:
<a-tree {...{ props, on, scopedSlots }} />
}
</a-spin>
</div>
</div>
<div class="swiper-scrollbar" />
<div class="yo-tree-layout--content">
<a-spin style={{ height: '100%' }} spinning={this.loading}>
<a-icon slot="indicator" type="loading" spin />
{
!this.loading && !this.list.length ?
<a-empty description={false} class="ant-list-empty-text">
<template slot="image">
<a-icon class="h3 mt-xl mb-md" type="smile" />
<p>暂无数据</p>
</template>
</a-empty>
:
<a-tree {...{ props, on, scopedSlots }} />
}
</a-spin>
</div>
</a-layout-sider>
<a-layout-content>