elementplus+splitpanes實(shí)現(xiàn)左右拖動(dòng)控制寬度的項(xiàng)目實(shí)踐
本文主要介紹了elementplus+splitpanes實(shí)現(xiàn)左右拖動(dòng)控制寬度,具體如下“

關(guān)鍵代碼
- 安裝splitpanes
npm install --save-dev @types/splitpanes
- 關(guān)鍵代碼
<template>
<splitpanes class="custom-panes" :min-percent="10" :max-percent="90" @resize="handleResize">
<pane :size="leftWidth" :min-size="15" :max-size="40">
左側(cè)內(nèi)容
</pane>
<pane :size="100 - leftWidth">
右側(cè)內(nèi)容
</pane>
</splitpanes>
</template>
<script lang="ts" setup>
import { Splitpanes, Pane } from 'splitpanes'
import 'splitpanes/dist/splitpanes.css'
// 動(dòng)態(tài)寬度(帶持久化)
const leftWidth = ref(localStorage.getItem('splitWidth') ? Number(localStorage.getItem('splitWidth')) : 20)
const handleResize = (e: any) => {
if (e[0]?.size) {
leftWidth.value = e[0].size
localStorage.setItem('splitWidth', e[0].size.toString())
}
}
</script >
<style scoped>
/* 容器高度設(shè)置 */
.custom-panes {
height: calc(100vh - 100px); /* 根據(jù)實(shí)際布局調(diào)整 */
}
/* 左側(cè)邊框容器 */
.border-container {
border: 0;
height: 100%;
padding: 0;
overflow: auto;
}
/* 拖拽條樣式(穿透作用域)*/
:deep(.splitpanes__splitter) {
background: #f0f0f0;
width: 6px !important; /* 橫向布局時(shí)為垂直分割線 */
position: relative;
&::before {
content: '';
position: absolute;
left: 1px;
top: 50%;
transform: translateY(-50%);
width: 2px;
height: 20px;
background: #ddd;
}
&:hover {
background: #e0e0e0;
}
}
/* 響應(yīng)式處理 */
@media (max-width: 768px) {
.custom-panes {
flex-direction: column; /* 移動(dòng)端改為垂直布局 */
}
:deep(.splitpanes__splitter) {
width: 100% !important; /* 橫向分割線 */
height: 6px !important;
&::before {
width: 20px;
height: 2px;
left: 50%;
top: 1px;
transform: translateX(-50%);
}
}
}
</style>到此這篇關(guān)于elementplus+splitpanes實(shí)現(xiàn)左右拖動(dòng)控制寬度的項(xiàng)目實(shí)踐的文章就介紹到這了,更多相關(guān)elementplus splitpanes 左右拖動(dòng)寬度內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
- Vue中使用elementui與Sortable.js實(shí)現(xiàn)列表拖動(dòng)排序
- 關(guān)于Element UI table 順序拖動(dòng)方式
- vue/Element?UI實(shí)現(xiàn)Element?UI?el-dialog自由拖動(dòng)功能實(shí)現(xiàn)
- 解決element-ui table設(shè)置列fixed時(shí)X軸滾動(dòng)條無(wú)法拖動(dòng)問(wèn)題
- vue使用Element的Tree樹(shù)形控件實(shí)現(xiàn)拖動(dòng)改變節(jié)點(diǎn)順序方式
- element plus tree拖動(dòng)節(jié)點(diǎn)交換位置和改變層級(jí)問(wèn)題(解決方案)
相關(guān)文章
vue-cropper插件實(shí)現(xiàn)圖片截取上傳組件封裝
這篇文章主要為大家詳細(xì)介紹了vue-cropper插件實(shí)現(xiàn)圖片截取上傳組件封裝,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-05-05
element-UI el-table修改input值視圖不更新問(wèn)題
這篇文章主要介紹了element-UI el-table修改input值視圖不更新問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2024-02-02
vue-pdf打包后無(wú)法預(yù)覽問(wèn)題及修復(fù)方式
這篇文章主要介紹了vue-pdf打包后無(wú)法預(yù)覽問(wèn)題及修復(fù)方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2024-03-03
Vue一個(gè)動(dòng)態(tài)添加background-image的實(shí)現(xiàn)
這篇文章主要介紹了Vue一個(gè)動(dòng)態(tài)添加background-image的實(shí)現(xiàn)方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-03-03
Vue3中實(shí)現(xiàn)微信掃碼登錄的步驟和代碼示例
在 Vue 3 中實(shí)現(xiàn)微信掃碼登錄,涉及到前端生成二維碼、監(jiān)聽(tīng)微信回調(diào)以及與后端的交互,本文給大家介紹了一個(gè)詳細(xì)的實(shí)現(xiàn)步驟和代碼示例,對(duì)大家的學(xué)習(xí)或工作有一定的幫助,需要的朋友可以參考下2024-07-07
vue-draggable實(shí)現(xiàn)pc端拖拽效果
這篇文章主要為大家詳細(xì)介紹了vue-draggable實(shí)現(xiàn)pc端拖拽效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-04-04
Vue項(xiàng)目部署后首頁(yè)白屏問(wèn)題排查與解決方法
在部署 Vue.js 項(xiàng)目時(shí),有時(shí)會(huì)遇到首頁(yè)加載后出現(xiàn)白屏的情況,這可能是由于多種原因造成的,本文將介紹一些常見(jiàn)的排查方法和解決方案,幫助開(kāi)發(fā)者快速定位問(wèn)題并解決,感興趣的小伙伴跟著小編一起來(lái)看看吧2024-08-08

