使用getBoundingClientRect 方式: this.$element('box1').getBoundingClientRect({ success: function (data) { const { top, bottom, left, right, width, height } = data; prompt.showToast({ message: `getBoundingClientRect结果: width:${width}, height:${height}, top:${top}, bottom:${bottom}, left:${left}, right:${right}` }) }, fail: (errorData, errorCode) => { prompt.showToast({ message: `错误原因:${JSON.stringify(errorData)}, 错误代码:${errorCode}` }) }, complete: function () { console.info('complete') } }) |