又是一个坑,和vue的生命周期有关,必须要在从mounted开始拿,才能拿得到里面的Dom元素
下面是获取元素的高度,可以试下
mounted() {
console.log(window.getComputedStyle(this.$refs.alltab.$el, null).height);
console.log("he -- ", this.$refs.alltab.$el);
console.log("he -- ", this.$refs.alltab.$el.style.height);
},
顺便写一下设置style属性 (再标签里面写属性)
:style="{height:tabHeight}
手机扫一扫
移动阅读更方便
你可能感兴趣的文章