Vue.JS 的简约但完美的自定义滚动条组件(使用了 utatti/perfect-scrollbar,所以如果遇到某些问题,可以查看 perfect-scrollbar
仓库)
Minimalistic but perfect custom scrollbar component for Vue.JS(using utatti/perfect-scrollbar, so if you have any question, you also can check the perfect-scrollbar
repo)
众所周知,谷歌浏览器支持自定义滚动条,但是火狐或其他浏览器不支持,如果你希望你的网站更完美,就用这个组件吧~
As you know, Chrome support custom scrollbar, but Firefox or other browsers don't support it, if you want your website perfect, please use this component~
vue-custom-scrollbar
是 Vue.JS 的一个简约但完美的自定义滚动条组件
vue-custom-scrollbar
is minimalistic but perfect scrollbar component for Vue.JS.
- 不改变设计布局 / No change on design layout
- 不需要手动操作 DOM / Don't need manipulate DOM manually
- 使用普通的
scrollTop
andscrollLeft
/ Use plainscrollTop
andscrollLeft
- 滚动条样式可完全自定义 / Scrollbar style is fully customizable
- 布局更改后更新 / Efficient update on layout change
<template>
<div>
<vue-custom-scrollbar class="scroll-area" :settings="settings" @ps-scroll-y="scrollHanle">
<img src="http://utatti.github.io/perfect-scrollbar/azusa.jpg" height="720" width="1280" alt="">
</vue-custom-scrollbar>
</div>
</template>
<script>
/**
* For Vue2/Vue3
*/
import vueCustomScrollbar from 'vue-custom-scrollbar'
import "vue-custom-scrollbar/dist/vueScrollbar.css"
/**
* For vite
*/
import vueCustomScrollbar from 'vue-custom-scrollbar/src/vue-scrollbar.vue'
export default {
components: {
vueCustomScrollbar
},
data() {
return {
settings: {
suppressScrollY: false,
suppressScrollX: false,
wheelPropagation: false
}
}
},
methods: {
scrollHanle(evt) {
console.log(evt)
}
}
}
</script>
<style >
.scroll-area {
position: relative;
margin: auto;
width: 600px;
height: 400px;
}
</style>