当前位置: 首页 > ai >正文

element-plus + splitpanes 实现左右拖动控制宽度

在这里插入图片描述
关键代码

  1. 安装splitpanes
npm install --save-dev @types/splitpanes
  1. 关键代码
<template><splitpanes class="custom-panes" :min-percent="10" :max-percent="90" @resize="handleResize"><pane :size="leftWidth" :min-size="15" :max-size="40">左侧内容</pane><pane :size="100 - leftWidth">右侧内容</pane></splitpanes>
</template><script lang="ts" setup>
import { Splitpanes, Pane } from 'splitpanes'
import 'splitpanes/dist/splitpanes.css'// 动态宽度(带持久化)
const leftWidth = ref(localStorage.getItem('splitWidth') ? Number(localStorage.getItem('splitWidth')) : 20)const handleResize = (e: any) => {if (e[0]?.size) {leftWidth.value = e[0].sizelocalStorage.setItem('splitWidth', e[0].size.toString())}
}
</script ><style scoped>
/* 容器高度设置 */
.custom-panes {height: calc(100vh - 100px); /* 根据实际布局调整 */
}/* 左侧边框容器 */
.border-container {border: 0;height: 100%;padding: 0;overflow: auto;
}/* 拖拽条样式(穿透作用域)*/
:deep(.splitpanes__splitter) {background: #f0f0f0;width: 6px !important; /* 横向布局时为垂直分割线 */position: relative;&::before {content: '';position: absolute;left: 1px;top: 50%;transform: translateY(-50%);width: 2px;height: 20px;background: #ddd;}&:hover {background: #e0e0e0;}
}/* 响应式处理 */
@media (max-width: 768px) {.custom-panes {flex-direction: column; /* 移动端改为垂直布局 */}:deep(.splitpanes__splitter) {width: 100% !important; /* 横向分割线 */height: 6px !important;&::before {width: 20px;height: 2px;left: 50%;top: 1px;transform: translateX(-50%);}}
}
</style>
http://www.xdnf.cn/news/3117.html

相关文章:

  • STM32F10X OLED屏幕点亮
  • 从Ping到iperf3:深度实战无线网络压测与优化指南
  • C语言之操作符
  • 基本算法之龟速乘
  • 最新DeepSeek-Prover-V2-671B模型 简介、下载、体验、微调、数据集:专为数学定理自动证明设计的超大垂直领域语言模型(在线体验地址)
  • 在原生代码(非webpack)里使用iview的注意事项
  • shell---expect
  • MySQL 中 redo log、undo log 以及 bin log 的区别
  • 北京亦庄机器人马拉松:人机共跑背后的技术突破与产业启示
  • 【Linux】记录一个有用PS1
  • 自创天炎十二戟算法设计,禁止抄袭
  • Elasticsearch:没有 “AG” 的 RAG?
  • 解决STM32待机模式无法下载程序问题的深度探讨
  • 论文阅读:2024 ACM SIGSAC Membership inference attacks against in-context learning
  • 《算法笔记》10.6小节——图算法专题->拓扑排序 问题 C: Legal or Not
  • Spring 转发 form-data 文件上传请求时中文文件名乱码
  • 【大模型面试每日一题】Day 4:低资源语言建模方案
  • vue3 打字机效果
  • 【CUDA pytorch】
  • DAPO:对GRPO的几点改进
  • 模式识别的基本概念与理论体系
  • 智能机器人在物流行业的应用:效率提升与未来展望
  • pycharm导入同目录下文件未标红但报错ModuleNotFoundError
  • iVX 开源战略:多维突破下的产业生态革新与未来图景
  • MCP的基础知识
  • C++从入门到实战(十一)详细讲解C/C++语言中内存分布与C与C++内存管理对比
  • 一种动态分配内存错误的解决办法
  • Chrome插件备忘
  • Godot笔记:入门索引
  • 卷积神经网络