vue拉伸div边框加高div 类似于浏览器F12控制台那样的拉高效果

vue拉伸div边框加高div 类似于浏览器F12控制台那样的拉高效果


直接上代码了 复制过去即可使用

<template>
  <div>
    <div id="app">
      <div class="box-bottom" ref="drag_box" :style="'height:'+realBoxHeight+'px'" @mouseup="mouseUpHandleelse($event)">
        <div
          class="box-click"
          @mousedown="mouseDownHandleelse($event)"
          @mouseup="mouseUpHandleelse($event)"
        ></div>1
      </div>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      boxHeight: undefined, //当前容器高度
      boxTopHeight: undefined, //容器距离顶部距离
      realBoxHeight: undefined //实际高度
    };
  },
  methods: {
    mouseDownHandleelse(e) {
      this.boxTopHeight = this.$refs.drag_box.offsetTop; //容器距离顶部距离
      this.boxHeight = this.$refs.drag_box.offsetHeight; //当前容器高度
      console.log(this.boxHeight);
      window.onmousemove = this.mouseMoveHandleelse;
    },
    // 鼠标移动
    mouseMoveHandleelse(event) {
      this.realBoxHeight = this.boxHeight + (this.boxTopHeight - event.clientY +86);
    },
    mouseUpHandleelse(e) {
      console.log(1);
      window.onmousemove = null;
    }
  }
};
</script>

<style lang="scss" scoped>
.box-bottom {
  position: absolute;
  background-color: #FFF;
  z-index: 999;
  bottom: 0;
  height: 40%;
  width: 100%;
  .box-click {
    height: 2px;
    background-color: gray;
    cursor: n-resize;
  }
}
</style>


//----vastwu
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值