From 714a5eb41a56055fe249761ae4427b34fbe5c677 Mon Sep 17 00:00:00 2001 From: xiaosi <2652281683@qq.com> Date: Wed, 13 Dec 2023 11:22:56 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E6=96=B0=E5=A2=9E=E3=80=91=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E6=8C=87=E4=BB=A4=EF=BC=9Av-scrollbar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.js | 1 + src/plugins/directives.js | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 src/plugins/directives.js diff --git a/src/main.js b/src/main.js index 8fb3253..b3c8496 100644 --- a/src/main.js +++ b/src/main.js @@ -3,6 +3,7 @@ import store from '@/stores'; import router from '@/router'; import TDesignVue from '@/plugins/TDesign-vue'; // TDesign按需引入 import '@/plugins/components'; +import '@/plugins/directives'; import '@/styles/common.less'; // 自定义全局样式表 app.use(store); diff --git a/src/plugins/directives.js b/src/plugins/directives.js new file mode 100644 index 0000000..de6ec34 --- /dev/null +++ b/src/plugins/directives.js @@ -0,0 +1,22 @@ +import app from '@/app'; +import { OverlayScrollbars } from 'overlayscrollbars'; + +// 滚动条 +app.directive('scrollbar', (el, binding) => { + const { arg: enable } = binding; + if (!enable) return; + const { padding } = binding.modifiers; + console.log(padding); + OverlayScrollbars(el, { + paddingAbsolute: !!padding, + overflow: { + x: 'hidden', + y: 'scroll', + }, + scrollbars: { + theme: 'os-theme-light', + autoHide: 'leave', + autoHideDelay: 300, + }, + }); +});