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