import React,{Component} from 'react'
import {AppRegistry,StyleSheet,Text,View,Image,TouchableOpacity} from 'react-native'
class App extends Component {
state = {
likes: 0
};
onPress = () => {
const {likes} = this.state;
this.setState({
likes: likes + 1
});
};
render() {
return(
<View>
<TouchableOpacity onPress={this.onPress}>
<Image
style = {styles.image}
source = {{
uri: 'http://img.hb.aicdn.com/f16a90f723f26bc08104ca5623a509a695a4c00c1352-zYJ85p_fw658'
}}
/>
</TouchableOpacity>
<Text>{this.state.likes}</Text>
</View>
)
}
}
2019-01-15
猜你喜欢
转载自blog.csdn.net/weixin_33832340/article/details/87060448
今日推荐
周排行