React Native获取ListView上row的点击TouchableOpacity获取其ref

来源:互联网 发布:淘宝内衣买家秀看不到 编辑:程序博客网 时间:2024/05/22 01:32

_renderRow(){

   return(

        <VIew>

             <TouchableOpacity ref={touchImage => this.touchImage =touchImage} onPress={this.}>

                 <Image />//在renderRow里面我们无法获取Image的ref所以我们将ref设为他的父容器TouchableOpacity

</TouchableOpacity>

        </View>

   )

}


touchEvent(event){

   //获取TouchOpacity的ref,以及TouchOpacity的measure

event._targetInst.measure((x, y, width, height, locationX, locationY)=>{})

}



这样我们就可以很轻松的获取Listview上的cell里面的各种组件坐标了

0 0
原创粉丝点击