本人小白一枚,记录开发中碰到的问题
要获取微信小程序内元素高度,可以使用
const query = wx.createSelectorQuery() //定义query
query.select('#txt_medium').boundingClientRect() //获取元素参数
query.exec((res) => {
console.log(res) //可以得到元素高度、距离顶部的top值、宽度等,单位为px
})
获取微信小程序屏幕高度和宽度,单位:px
height: wx.getSystemInfoSync().windowHeight,
width: wx.getSystemInfoSync().windowWidth