您当前的位置: 首页 >  cmmboy1990 ui

ElementUI el-main高度问题

cmmboy1990 发布时间:2021-07-21 15:33:22 ,浏览量:3

ElementUI el-main高度问题

原因:布局=> 头部、主页面、底部 el-main 需要充满屏幕

解决:1.public 中的index.html 中,清楚浏览器边距


      html,
      body,
      #app {
          height: 100%;
          margin: 0px;
          padding: 0px;
      }
  

2.主页面布局代码:



  

    
      
    

    
      
      
      
        
      
      

    


    
      Copyright © 2020 - 2021 . xx公司.All Rights Reserved
    


  



import TopNav from '@/components/TopNav'

export default {
  name: 'index',
  components: {
    TopNav
  },
  data() {
    return {
      defaultHeight: {
        height: ""
      }
    };
  },


  methods: {
    //定义方法,获取高度减去头尾
    getHeight() {
      this.defaultHeight.height = window.innerHeight - 120 + "px";
    }
  },

  created() {
    //页面创建时执行一次getHeight进行赋值,顺道绑定resize事件
    window.addEventListener("resize", this.getHeight);
    this.getHeight();
  }

}


.el-header {
  background-color: #517859;
}

.el-main {
  background-color: #1359a0;
}




效果 在这里插入图片描述 头部组件代码:



  
  
    主页面
    消息中心

  
  



export default {
  data() {
    return {
      activeIndex: '1',
    };
  },
  methods: {
    handleSelect(key) {
      // console.log(key);
      console.log(key);
      if (key==1){
        this.$router.push({path: 'home'})
      }
      if (key==2){
        this.$router.push({path: 'personal'})
      }
    }
  }
}





关注
打赏
1688896170
查看更多评论

cmmboy1990

暂无认证

  • 3浏览

    0关注

    131博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文
立即登录/注册

微信扫码登录

0.0626s