随手记:若依后台系统部分页面调整padding,调整左侧菜单缩放

代码

if(this.$route.path == '/order/transaction/printLabel') {
        this.appMainPdding = '0px';
        this.$store.dispatch('app/toggleSideBarHide', true);
        document.querySelector('.navbar').style.display = 'none';
        document.querySelector('.tags-view-container').style.display = 'none';
        document.querySelector('.sidebar-container').style.display = 'none';
        // document.querySelector('.main-container').style.marginLeft = '0px';
      }else{
        this.appMainPdding = '20px';
        this.$store.dispatch('app/toggleSideBarHide', false);
        document.querySelector('.navbar').style.display = 'block';
        document.querySelector('.tags-view-container').style.display = 'block';
        document.querySelector('.sidebar-container').style.display = 'block';
        // document.querySelector('.main-container').style.marginLeft = '200px';
      }
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
好的,请稍等,我正在获取相关代码。 以下是一个简单的示例代码,仅供参考: 1. 定义菜单数据结构 ```javascript const menuData = [ { id: '1', title: '仪表盘', icon: 'dashboard', path: '/dashboard', }, { id: '2', title: '文章管理', icon: 'file-text', path: '/articles', }, { id: '3', title: '用户管理', icon: 'user', path: '/users', }, ] ``` 2. 使用Vue动态绑定数据生成菜单 ```html <template> <div class="menu-container"> <el-menu :default-active="activePath" :collapse="collapsed" :unique-opened="true" router > <el-submenu v-for="menuItem in menuList" :key="menuItem.id" :index="menuItem.path"> <template v-if="menuItem.children"> <span slot="title"> <i :class="'el-icon-' + menuItem.icon"></i> <span>{{ menuItem.title }}</span> </span> <el-menu-item v-for="subMenuItem in menuItem.children" :key="subMenuItem.path" :index="subMenuItem.path"> {{ subMenuItem.title }} </el-menu-item> </template> <template v-else> <el-menu-item :index="menuItem.path"> <i :class="'el-icon-' + menuItem.icon"></i> <span>{{ menuItem.title }}</span> </el-menu-item> </template> </el-submenu> </el-menu> </div> </template> <script> export default { name: 'Menu', data() { return { menuList: [], activePath: '', } }, created() { // 获取菜单数据 this.menuList = menuData // 设置默认激活的菜单项 this.activePath = this.$route.path }, watch: { // 监听路由变化,切换激活的菜单项 $route(to) { this.activePath = to.path }, }, } </script> <style scoped> .menu-container { padding: 20px; } </style> ``` 3. 实现动态添加和删除菜单项 ```javascript export default { // ... methods: { addMenuItem() { const newItem = { id: '4', title: '新菜单项', icon: 'star-on', path: '/new-item', } this.menuList.push(newItem) }, removeMenuItem() { const removedItem = this.menuList.pop() console.log(`已删除菜单项:${removedItem.title}`) }, }, } ``` 在上述代码,`addMenuItem` 方法用于在菜单列表末尾添加一个新的菜单项,`removeMenuItem` 方法用于从菜单列表末尾删除一个菜单项。您可以根据自己的需求修改这些方法。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

peachSoda7

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值