0
我必须在measure()
函数的帮助下测量几个值。
因为是异步操作,我只能写:同时调用多个“测量”操作
this.refContainerView.measure((x, y, width, height, pageX, pageY) => {
const containerViewHeight = height
this.refCommentList.measure((x, y, width, height, pageX, pageY) => {
const commentListOffset = pageY
const commentListHeight = height
// do something
})
})
,如果需要测量更多的组件,它看起来像一个回调地狱。
是否可以同步编写代码,例如在await
或其他帮助下,例如:
const contaierView = this.refContainerView.measure()
const commentList = this.refCommentList.measure()
// and then do something with
contaierView {x, y, width, height, pageX, pageY}
commentList {x, y, width, height, pageX, pageY}