微信小程序 JS 獲取View 和 屏幕相關屬性(高度、寬度等等)


 

 

 

 

 

        wx.getSystemInfo({success: function (res) {thisWidth = res.windowWidth;}});        
        that.setData({view_Width: thisWidth / ColIndex})//設置列寬  
        console.log('----------------------');
        console.log('列數' + ColIndex + ' ; ' + '屏幕寬度:' + thisWidth 
        + ';單元格寬度:' + thisWidth / ColIndex);  
        console.log(requestarray[0].ArraylistData);
        that.setData({ array: requestarray[0].ArraylistData})//設置列寬

 

 

 

 

 

    var thisWidth;//屏幕寬度
    //創建節點選擇器
    var query = wx.createSelectorQuery();
    //選擇id
    query.select('#AutoTableItem').boundingClientRect()
    query.exec(function (res) {
      //res就是 所有標簽為mjltest的元素的信息 的數組
      console.log(res); 
      thisWidth = res[0].width; 
    });

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM