mirror of
https://github.com/m-xlsea/ruoyi-plus-soybean.git
synced 2025-09-24 07:49:47 +08:00
fix(projects): 修复tab过多时样式坍塌,添加tab横向滚动
This commit is contained in:
43
src/components/custom/BetterScroll/index.vue
Normal file
43
src/components/custom/BetterScroll/index.vue
Normal file
@ -0,0 +1,43 @@
|
||||
<template>
|
||||
<div ref="scrollbar" class="w-full h-full text-left">
|
||||
<div ref="scrollbarContent" class="inline-block" :class="{ 'h-full': !options.scrollY }">
|
||||
<slot></slot>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, watch } from 'vue';
|
||||
import type { PropType } from 'vue';
|
||||
import BScroll from '@better-scroll/core';
|
||||
import type { Options } from '@better-scroll/core';
|
||||
import { useElementSize } from '@vueuse/core';
|
||||
|
||||
const props = defineProps({
|
||||
options: {
|
||||
type: Object as PropType<Options>,
|
||||
required: true
|
||||
}
|
||||
});
|
||||
|
||||
const scrollbar = ref<HTMLElement | null>(null);
|
||||
const bsInstance = ref<BScroll | null>(null);
|
||||
const scrollbarContent = ref<HTMLElement | null>(null);
|
||||
|
||||
function initBetterScroll() {
|
||||
bsInstance.value = new BScroll(scrollbar.value!, props.options);
|
||||
}
|
||||
|
||||
// 滚动元素发生变化,刷新BS
|
||||
const { width, height } = useElementSize(scrollbarContent);
|
||||
watch([() => width.value, () => height.value], () => {
|
||||
if (bsInstance.value) {
|
||||
bsInstance.value.refresh();
|
||||
}
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
initBetterScroll();
|
||||
});
|
||||
</script>
|
||||
<style scoped></style>
|
@ -16,7 +16,7 @@
|
||||
@mouseenter="setTrue"
|
||||
@mouseleave="setFalse"
|
||||
>
|
||||
<span>
|
||||
<span class="whitespace-nowrap">
|
||||
<slot></slot>
|
||||
</span>
|
||||
<div v-if="closable" class="pl-10px">
|
||||
|
@ -14,7 +14,7 @@
|
||||
:primary-color="primaryColor"
|
||||
/>
|
||||
</div>
|
||||
<span class="relative z-2">
|
||||
<span class="relative whitespace-nowrap z-2">
|
||||
<slot></slot>
|
||||
</span>
|
||||
<div v-if="closable" class="pl-18px">
|
||||
|
@ -3,5 +3,6 @@ import IconClose from './IconClose/index.vue';
|
||||
import ButtonTab from './ButtonTab/index.vue';
|
||||
import ChromeTab from './ChromeTab/index.vue';
|
||||
import ShadowCard from './ShadowCard/index.vue';
|
||||
import BetterScroll from './BetterScroll/index.vue';
|
||||
|
||||
export { CountTo, IconClose, ButtonTab, ChromeTab, ShadowCard };
|
||||
export { CountTo, IconClose, ButtonTab, ChromeTab, ShadowCard, BetterScroll };
|
||||
|
@ -1,2 +1,2 @@
|
||||
export { AppProviderContent, SystemLogo, ExceptionSvg, LoginBg, BannerSvg, HoverContainer } from './common';
|
||||
export { CountTo, IconClose, ButtonTab, ChromeTab, ShadowCard } from './custom';
|
||||
export { CountTo, IconClose, ButtonTab, ChromeTab, ShadowCard, BetterScroll } from './custom';
|
||||
|
Reference in New Issue
Block a user