美文网首页
vue自适应pc端界面

vue自适应pc端界面

作者: 五四青年_4e7d | 来源:发表于2020-05-18 23:36 被阅读0次

页面高度自适应element-ui框架:应用于vue后台管理系统,大屏,整理源码如下:

<template>
  <div class="hello">
    <el-container>
  <el-header class="Header">Header</el-header>
  <el-main :style="height" class="main">Main</el-main>
  <!-- <el-footer>Footer</el-footer> -->
</el-container>
  </div>
</template>
<script>

export default {
  data () {
    return {
      //高度自适应
      height:{
        height:''
      },
      //高度自适应:
      clientHeight:document.documentElement.clientHeight
    }
  },
  created(){
  
  },
  mounted(){
    this.getHeight()
   window.onresize = () =>{
     this.clientHeight = document.documentElement.clientHeight
   }
  },
  methods:{
    //获取高度方法:
    getHeight(){
      this.height.height = window.innerHeight - 50 + 'px'
    }
  },
  watch:{
    clientHeight(newValue,oldValue){
      console.log(newValue)
      var h = newValue - 50
      this.height.height = h + 'px'
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.hello{
  width:100%;
  border:1px solid red;
  box-sizing: border-box;
  position: absolute;
  top:0px;
  left:0px;
}
.Header{
  background:green;
  height:50px;
}
.main{
  height:calc(100% - 50px);
}
</style>
image.png

相关文章

  • vue自适应pc端界面

    前提 制作网页时,通常会要求适应各种的屏幕尺寸。因此就要求写出来的前端页面是能够自适应的。 目前有许多的前端库是支...

  • vue自适应pc端界面

    前提 制作网页时,通常会要求适应各种的屏幕尺寸。因此就要求写出来的前端页面是能够自适应的。 目前有许多的前端库是支...

  • vue自适应pc端界面

    页面高度自适应element-ui框架:应用于vue后台管理系统,大屏,整理源码如下:

  • 前端自适应问题

    自适应问题 PC端随屏幕分辨率与窗口大小自适应 参考文献 vue项目PC端随屏幕分辨率与窗口大小自适应[https...

  • web自适应

    简单事情简单做-宽度自适应 所谓宽度自适应严格来说是一种PC端的自适应布局方式在移动端的延伸。在处理PC端的前端界...

  • vue实现pc端手机端自适应

    https://www.cnblogs.com/maggieq8324/p/12099271.html[https...

  • vue pc端自适应屏幕缩放

    一、npm安装依赖 二、新建文件夹 在src下面新建utils文件夹,并新建一个js文件,取名为【flexible...

  • 为友谊

    一、PC端开发(Vue + Webpack + ElementUi) (一)常规PC端 1、Element-UI ...

  • pc端自适应

    原链接 https://waliblog.com/css/2018/03/19/compatible.html 配...

  • PC端自适应

    1920设计稿 app.vue 浏览器查看效果 1、使用F12打开控制台,切换到移动端浏览方式2、在机型切换选项里...

网友评论

      本文标题:vue自适应pc端界面

      本文链接:https://www.haomeiwen.com/subject/sjgeohtx.html