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>
相关推荐
墨林陌7 分钟前
翻完 DeepSeek 的 GitHub 仓库,我发现 V5 的发布路已经修好了
前端
Antruly23 分钟前
uvscope:Web 调试界的瑞士军刀
前端
计算机魔术师34 分钟前
Anthropic S-1 披露:半年前发布的模型,已贡献不了多少收入了
前端
qq_364682151 小时前
录音APP怎么切换语言?多语言版本如何使用
java·服务器·前端
志尊宝1 小时前
AI原生前端开发(037):AI辅助的Vue 3开发最佳实践
前端·vue.js·ai-native
中科三方1 小时前
AI时代新攻击面:悬空DNS记录正在成为黑客的低成本入侵入口
服务器·前端·人工智能
努力变的更好1 小时前
H5与小程序之间的回调
前端·小程序·apache
汤米粥2 小时前
目前流行的前端 CSS 框架
前端·css·bootstrap·ant design·‌tailwind css·bulma
砚凝霜2 小时前
CTF Misc 签到 GXUST·CTF:查看源码 + HTML 注释 + Base64 解码(附 Base64 原理)
前端·html
徐小夕2 小时前
扒了JitWord的源码,我终于搞懂了企业级在线Word到底有多难写
前端·vue.js·github