uni.getSystemInfo({
success: function(res) { // res - 各种参数
console.log(res.windowWidth); // 屏幕的宽度
let info = uni.createSelectorQuery().select(".类名");
info.boundingClientRect(function(data) { //data - 各种参数
console.log(data.width) // 获取元素宽度
}).exec()
}
});
转载于:https://www.cnblogs.com/lymconch/p/11286795.html