vue在渲染后再获取该元素的高度

今天开发时需要获取某个元素的高度,但因为用到vue,没渲染完之前获取的高度是不准确的,然后上网搜了下,找到了方法

 

 1  watch: {  //hotkeyList渲染完后,获取高度
 2             hotkeyList:function() {
 3                 this.$nextTick(function(){
 4                     var headheight = $('.search-head').height();
 5                     var hotheight = $('.hot-wrap').height();
 6                     var w = $(window).height();
 7                     console.log(headheight);
 8                     console.log(hotheight);
 9                     console.log(w);
10                     vm.historyheight = w - headheight - hotheight;
11                     console.log(vm.historyheight);
12                 });               
13             }
14         },

 

posted on 2018-07-24 17:12  super_bobo  阅读(9326)  评论(0编辑  收藏  举报