vue3鼠標(biāo)拖拽滑動(dòng)效果實(shí)現(xiàn)demo
vue3-dragscroll來(lái)實(shí)現(xiàn)
使用element-plus在頁(yè)面里寫一個(gè)表格,表格有橫向和豎向滾動(dòng)條,想實(shí)現(xiàn)表格可以鼠標(biāo)拖拽滾動(dòng)。
可以用vue3-dragscroll來(lái)實(shí)現(xiàn),首先需要在css里隱藏掉表格的滾動(dòng)條,將表格的父級(jí)設(shè)置固定的寬高,并在父級(jí)標(biāo)簽上增加v-dragscroll指令。
<template>
<div class="data-table" v-dragscroll>
<el-table
:data="rowData"
border
:show-header="false"
table-layout="auto"
size="small"
>
<el-table-column
:prop="item.prop"
v-for="item of columns"
:key="item.prop"
:fixed="item.fixed ? true : false"
:width="item.width"
>
</el-table-column>
</el-table>
</div>
</template>
<script lang="ts" setup>
import { ref } from 'vue'
import { useDataTable } from './scripts/data-table'
const { columns, rowData } = useDataTable()
</script>
<style scoped lang="scss">
.data-table {
width: 630px;
height: 320px;
overflow: auto;
border: solid 1px #ebeef5;
&::-webkit-scrollbar {
width: 6px;
height: 6px;
}
&::-webkit-scrollbar-track {
width: 6px;
background: rgba(#101F1C, 0.1);
-webkit-border-radius: 2em;
-moz-border-radius: 2em;
border-radius: 2em;
}
&::-webkit-scrollbar-thumb {
background-color: rgba(144,147,153,.5);
background-clip: padding-box;
min-height: 6px;
-webkit-border-radius: 2em;
-moz-border-radius: 2em;
border-radius: 2em;
transition: background-color .3s;
cursor: pointer;
}
&::-webkit-scrollbar-thumb:hover {
background-color: rgba(144,147,153,.3);
}
}
:deep .el-table {
width: fit-content;
max-width: none;
border: none;
}
:deep .el-scrollbar__bar.is-vertical {
width: 0;
}
:deep .data-table thead {
height: 0;
display: block;
}
:deep .hide_line .el-table td.el-table__cell {
border-bottom: none;
}
:deep .data-table .el-table--small .el-table__cell {
padding: 0;
}
:deep .data-table .el-table--small .cell {
padding: 4px 8px;
}
:deep .data-table .hover .cell {
border-left: 1px solid blue;
border-right: 1px solid blue;
}
</style>全局安裝vue3-dragscroll
npm install vue3-dragscroll
在main.ts文件內(nèi)引入
import { createApp } from 'vue'
import '@/style/index.css'
import App from './App.vue'
import router from './router'
import Vue3Dragscroll from 'vue3-dragscroll'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
const app = createApp(App)
app.use(createPinia())
app.use(router)
app.use(ElementPlus, { locale: zhCn })
app.use(Vue3Dragscroll)
app.mount('#app')以上就是vue3鼠標(biāo)拖拽滑動(dòng)效果實(shí)現(xiàn)demo的詳細(xì)內(nèi)容,更多關(guān)于vue3鼠標(biāo)拖拽滑動(dòng)的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!
相關(guān)文章
解決echarts echarts數(shù)據(jù)動(dòng)態(tài)更新和dataZoom被重置問(wèn)題
這篇文章主要介紹了解決echarts echarts數(shù)據(jù)動(dòng)態(tài)更新和dataZoom被重置問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-07-07
使用Vant完成DatetimePicker 日期的選擇器操作
這篇文章主要介紹了使用Vant完成DatetimePicker 日期的選擇器操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-11-11
Vue?監(jiān)聽(tīng)視頻播放時(shí)長(zhǎng)的實(shí)例代碼
本文介紹了如何通過(guò)源碼實(shí)現(xiàn)對(duì)視頻實(shí)時(shí)時(shí)長(zhǎng)、播放時(shí)長(zhǎng)和暫停時(shí)長(zhǎng)的監(jiān)聽(tīng),詳細(xì)闡述了相關(guān)技術(shù)的應(yīng)用方法,幫助開發(fā)者更好地掌握視頻監(jiān)控技術(shù),提高用戶體驗(yàn)2024-10-10
vue3+ts封裝axios,無(wú)感刷新問(wèn)題
vue-lazyload圖片延遲加載插件的實(shí)例講解
uniapp+vue3路由跳轉(zhuǎn)傳參的實(shí)現(xiàn)

