王多静

这里是我的记事本

导航

vue获取某个标签的高度,渲染后的高度

 

需求: 想三边高度一致, 主要看截图 

 

代码

html:使用 this.$refs.inforTitleR.clientHeight 获取该元素的高度

 

js部分

// 先data里定义
comHeight: "126px",
// 数据赋值函数里   判断高度 让高度都==右侧的高度 注意减去增加的padding20
   this.$nextTick(function() {
      this.comHeight = this.$refs.inforTitleR.clientHeight - 20 + "px";
   });
  watch: {
    comHeight: {
      handler(newVal, oldVal) {
        if (newVal) {
          this.comHeight = newVal;
        }
      }
    }
  },

 

 

 

 css随便都可以,根据UI图等

 

posted on 2021-05-19 15:05  王多静  阅读(1979)  评论(0编辑  收藏  举报