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         },

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM