vue2.x elementui 固定顶部、左侧菜单与面包屑,自适应 iframe 页面布局

vue elementui 固定顶部、左侧菜单与面包屑,自适应 iframe 页面布局

疑问点:iframe无法高度100%,如果写了100%就会有滚动条,所以只写了99.5%

【效果图】

路由示例

javascript 复制代码
const routes = [
    {
        title: 'Index',
        path: '/',
        name: "Index",
        component: () => import('@/views/Index.vue'),
    },
    {
        title: 'TEST',
        path: '/TEST', // 使用内部页面时,路径为 "#/TEST"
        name: "TEST",
        component: () => import('@/views/TEST.vue'),
    },
]

页面完整代码

javascript 复制代码
<template>
  <div class="container">
    <div class="top">
      <el-menu :default-active="activeIndex" class="el-menu-demo" mode="horizontal" @select="handleSelect">
        <el-menu-item index="1">Home</el-menu-item>
        <el-submenu index="2">
          <template slot="title">Options</template>
          <el-menu-item index="2-1">Option1</el-menu-item>
          <el-menu-item index="2-2">Option2</el-menu-item>
          <el-submenu index="2-4">
            <template slot="title">Option3</template>
            <el-menu-item index="2-4-1">Option3-1</el-menu-item>
            <el-menu-item index="2-4-2">Option3-2</el-menu-item>
          </el-submenu>
        </el-submenu>
        <el-menu-item index="3" disabled>Msg</el-menu-item>
        <el-menu-item index="4"><a href="https://www.ele.me" target="_blank">Order</a></el-menu-item>
      </el-menu>
    </div>
    <div class="wrap">
      <div class="l">
        <p style="margin-top: 32px;">aside-bar</p>
      </div>
      <div class="r">
        <div class="bread-wrap">
          <el-breadcrumb separator="/">
            <el-breadcrumb-item>首页</el-breadcrumb-item>
            <el-breadcrumb-item><a href="/">活动管理</a></el-breadcrumb-item>
            <el-breadcrumb-item>活动列表</el-breadcrumb-item>
            <el-breadcrumb-item>活动详情</el-breadcrumb-item>
          </el-breadcrumb>
        </div>
        <div class="iframe-wrap">
          <iframe :src="iframeUrl" width="100%" height="99.5%" frameborder="0"></iframe>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      activeIndex: '1',
      // iframeUrl: '#/TEST',  // 关键点:使用内部页面的话,要按这样写
      iframeUrl: 'https://www.baidu.com',
    }
  },
  methods: {
    handleSelect(key, keyPath) {
      console.log(key, keyPath);
    }
  }
}
</script>

<style scoped lang="less">
.container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  color: #fff;

  &>.top {
    height: 48px;
    background: #212121;
  }

  &>.wrap {
    flex: 1;
    display: flex;
    height: 0;

    &>.l {
      width: 200px;
      background: #212121;
    }

    &>.r {
      overflow-y: hidden;
      display: flex;
      flex-direction: column;
      flex: 1;
      width: 0;
      background: #fff;

      .bread-wrap {
        display: flex;
        align-items: center;
        height: 48px;
      }

      .iframe-wrap {
        overflow-y: auto;
        flex: 1;
        height: 0;
      }
    }
  }
}

.el-menu {
  height: 100%;
  background: transparent;
}

/deep/.el-menu--horizontal>.el-submenu .el-submenu__title,
.el-menu--horizontal>.el-menu-item,
.el-menu--horizontal>.el-submenu .el-submenu__title {
  height: 48px;
  line-height: 48px;
  color: #ccc;
}

.el-menu--horizontal>.el-menu-item.is-active {
  color: #fff;
}

.el-menu.el-menu--horizontal {
  border-bottom: solid 1px #000;
}
</style>
相关推荐
weixin-a1530030831640 分钟前
【playwright篇】教程(十七)[html元素知识]
java·前端·html
ai小鬼头1 小时前
AIStarter最新版怎么卸载AI项目?一键删除操作指南(附路径设置技巧)
前端·后端·github
一只叫煤球的猫2 小时前
普通程序员,从开发到管理岗,为什么我越升职越痛苦?
前端·后端·全栈
vvilkim2 小时前
Electron 自动更新机制详解:实现无缝应用升级
前端·javascript·electron
vvilkim2 小时前
Electron 应用中的内容安全策略 (CSP) 全面指南
前端·javascript·electron
aha-凯心2 小时前
vben 之 axios 封装
前端·javascript·学习
遗憾随她而去.2 小时前
uniapp 中使用路由导航守卫,进行登录鉴权
前端·uni-app
xjt_09013 小时前
浅析Web存储系统
前端
喜欢敲代码的程序员3 小时前
SpringBoot+Mybatis+MySQL+Vue+ElementUI前后端分离版:项目搭建(一)
spring boot·mysql·elementui·vue·mybatis
foxhuli2293 小时前
禁止ifrmare标签上的文件,实现自动下载功能,并且隐藏工具栏
前端