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

vue一个超简单的菜单栏伸缩示例

代码

<template><div class="container"><!-- 左侧区域 --><div class="left-side" :style="{ width: leftWidth + 'px' }">左侧内容</div><!-- 右侧区域 --><div class="right-side" :style="{ left: leftWidth + 'px' }"><div class="content"><button @click="toggleLeftWidth">切换左侧宽度</button><p>右侧内容区域,占据剩余空间</p></div></div></div>
</template><script>
export default {data() {return {leftWidth: 200, // 初始宽度200pxisCollapsed: false}},methods: {toggleLeftWidth() {this.isCollapsed = !this.isCollapsed;this.leftWidth = this.isCollapsed ? 64 : 200;}}
}
</script><style lang="less" scoped>
.container {position: relative;width: 100%;height: 100vh;overflow: hidden;.left-side {position: fixed;left: 0;top: 0;height: 100%;background-color: blue;transition: width 0.3s ease;padding: 20px;box-sizing: border-box;}.right-side {position: fixed;top: 0;right: 0;bottom: 0;background-color: red;transition: left 0.3s ease;padding: 20px;box-sizing: border-box;overflow: auto;border-left: 1px solid #ddd;}
}button {padding: 8px 16px;background-color: #42b983;color: white;border: none;border-radius: 4px;cursor: pointer;margin-bottom: 20px;
}button:hover {background-color: #3aa876;
}
</style>

结果

http://www.lryc.cn/news/622067.html

相关文章:

  • 剧本杀小程序系统开发:重构推理娱乐生态
  • C语言第八章指针五
  • linux服务器查看某个服务启动,运行的时间
  • Chrome插件开发
  • 最长递增子序列-dp问题+二分优化
  • 智能巡检技术浅析
  • 最新chrome浏览器elasticsearch-head无法安装使用问题
  • 牛市暴跌后什么时候进入好
  • C++ 调试报错 常量中有换行符
  • NAS播放器的新星,一站式全平台媒体库管理工具『Cinemore』体验
  • 高通vendor app访问文件
  • 前端css学习笔记6:盒子模型
  • IP生意的天花板更高了吗?
  • 多路混音声音播放芯片型号推荐
  • Microsoft Visual Studio常用快捷键和Windows系统常用快捷键的整理
  • 深入解析五大通信协议:TCP、UDP、HTTP_HTTPS、WebSocket与GRPC
  • 【Leetcode hot 100】53.最大子数组和
  • 异步任务执行顺序
  • DataGear:一个免费开源的国产数据可视化分析平台
  • 经典BT的连接过程
  • 归并排序和统计排序
  • 智能工厂生产监控大屏-vue纯前端静态页面练习
  • AI智能体在软件测试中的应用与未来趋势
  • 开疆智能Ethernet转ModbusTCP网关连接测联无纸记录仪配置案例
  • python-pycharm切换python各种版本的环境与安装python各种版本的环境(pypi轮子下载)
  • C++第二十课:快递运费计算器 / 黑白配+石头剪刀布小游戏
  • SAP ALV导出excel 报 XML 错误的 /xl/sharedStrings.xml
  • 2025.08.09 江门两日游记
  • 4.2 寻址方式 (答案见原书 P341)
  • LLaMA Factory 是一个简单易用且高效的大型语言模型(Large Language Model)训练与微调平台。