微信小程序 JS 获取View 和 屏幕相关属性(高度、宽度等等)

时间:2024-04-29 00:46:06
        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;
});