我最近一直在学习React Native,但是还没有找到操作DOM的方法。
我试图通过点击TouchableHighlight来使我的图片向下移动几个像素,但是我尚未成功移动它,而且实际上我不知道该从哪里入手。
我的onclick函数有效,因为每次点击按钮时都会记录日志。
目前为止,我有以下代码:
export default class MainBody extends Component {
onclick = () => {
console.log('On click works')
};
render() {
return (
<ScrollView showsHorizontalScrollIndicator={false} style={Style.horList} horizontal={true}>
<View >
{/*i need to move this Image down!*/}
<Image source={require("./img/example.png")}/>
<View>
<Text style={Style.peopleInvited}>This is text</Text>
</View>
{/*When clicked on this touchable highlight!*/}
<TouchableHighlight onPress={this.onclick}}>
<Image source={require('./img/moveImg.png')}/>
</TouchableHighlight>
</View>
</ScrollView>
}
如果有人能帮我解决这个问题,那将不胜感激。非常感谢你的时间!