• vue 记录一个 自适应高度 ,可拖拽宽度的页面


    <!-- 扫码统计 -->
    <template>
      <div>
          <div id="box"  :style="{height:divHeight+'px'}">
            <div id="left">
                1111111111
            </div>
            <div id="resize"></div>
            <div id="right" >
                22222222222
            </div>
          </div>
      </div>
    </template>
    
    <script>
    export default {
        data(){
            return{
                screenWidth: window.innerWidth,
                screenHeight: window.innerHeight,
                divHeight: window.innerHeight - 110,
            }
        },
        created(){this.divHeight = window.innerHeight - 110;
        },
        mounted() {
            this.dragControllerDiv();
            this.screenWidth = document.body.clientWidth;
            this.screenHeight = document.body.clientHeight;
            window.onresize = () => {
                return (() => {
                    this.screenWidth = document.body.clientWidth;
                    this.screenHeight = document.body.clientHeight;
                })();
            };
        },
        methods:{
            dragControllerDiv() {
                let resize = document.getElementById("resize");
                let left = document.getElementById("left");
                let right = document.getElementById("right");
                let box = document.getElementById("box");
    
                resize.onmousedown = function (e) {
                    let startX = e.clientX;
                    resize.left = resize.offsetLeft;
                    document.onmousemove = function (e) {
                        let endX = e.clientX;
                        let moveLen = resize.left + (endX - startX);
                        let maxT = box.clientWidth - resize.offsetWidth;
                        if (moveLen < 100) moveLen = 100;
                        //   if (moveLen > maxT - 800) moveLen = maxT - 800
                        resize.style.left = moveLen;
                        left.style.width = moveLen + "px";
                        right.style.width = box.clientWidth - moveLen - 5 + "px";
                    };
                    document.onmouseup = function () {
                        document.onmousemove = null;
                        document.onmouseup = null;
                        resize.releaseCapture && resize.releaseCapture();
                    };
                    resize.setCapture && resize.setCapture();
                    return false;
                };
            },
        }
    }
    </script>
    
    <style scoped>
    .bigbox {
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }
    #box {
        flex: 1;
        width: 100%;
        height: 500px;
        position: relative;
        display: flex;
    }
    
    #left {
        width: calc(20% - 5px);
        height: 100%;
        overflow: auto;
        border:1px solid red;
    }
    
    #resize {
        position: relative;
        width: 5px;
        height: 100%;
        cursor: w-resize;
    }
    
    #right {
        width: 80%;
        height: 100%;
        overflow: hidden;
    }
    .flex {
        display: flex;
        margin-bottom: 10px;
        align-items: center;
    }
    
    </style>
    
    
    <style lang='scss' scoped></style>
  • 相关阅读:
    在CentOS 8 上 部署 .Net Core 应用程序
    Asp.Net Core 查漏补缺《一》 —— IStartFilter
    接口相关数据日志打印
    退款
    识别身份证
    生成二维码
    打造一款简单易用功能全面的图片上传组件
    Redis过期策略+缓存淘汰策略
    Redis主从复制
    .net 平台常用框架
  • 原文地址:https://www.cnblogs.com/fuyuanling/p/13700760.html
Copyright © 2020-2023  润新知