一种用 点+控件类名
var query = wx.createSelectorQuery(); //选择id var that = this; query.select(‘.progressBarCarrier‘).boundingClientRect(function (rect) { let width = rect.width console.log("矩形:" + JSON.stringify(rect)) let setpWidth = width / 25 // console.log("空你感觉:" + setpWidth) that.setData({ stepWidth: setpWidth }) }).exec();
另外一种用 #+控件id
let option = answers[idx] let optionName = "#opt" + bigIdx+idx var query = wx.createSelectorQuery(); //选择id var that = this; query.select(optionName).boundingClientRect(function (rect) { let height = rect.height console.log("选项尺寸:" + JSON.stringify(rect)) option.borderRadius = height console.log("选项字典:" + JSON.stringify(questions)) that.setData({ questionList: questions }) }).exec();