react-native ios模拟器触摸不起作用
问题描述:
我想写我的第一反应原生应用程序。我似乎无法获得“TouchableHighlight”的功能。我想我已经正确地包装了文本,但在IOS模拟器中没有任何反应。代码编译正确,模拟器启动,但是,无论我点击开始文本多少次都没有任何反应。react-native ios模拟器触摸不起作用
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
TouchableHighlight,
Text,
View
} from 'react-native';
var StopWatch = React.createClass({
render: function(){
return <View style={styles.container}>
<View style={[styles.header, this.border('yellow')]}>
<View style={[styles.timerWrapper , this.border('red')]}>
<Text>
00:00:00
</Text>
</View>
<View style={[styles.buttonWrapper , this.border('green')]}>
{this.startStopButton()}
{this.lapButton()}
</View>
</View>
<View style={[styles.footer, this.border('blue')]}>
<Text>
I am a list of Laps
</Text>
</View>
</View>
},
startStopButton: function() {
return <TouchableHighlight underlayColor="gray" onPRess={this.handleStartPress}>
<Text>
Start
</Text>
</TouchableHighlight>
},
lapButton: function() {
return <View>
<Text>
Lap
</Text>
</View>
},
handleStartPress: function() {
console.log('Start was pressed');
},
border: function (color) {
return {
borderColor: color,
borderWidth: 4
}
}
});
var styles = StyleSheet.create({
container:{
flex: 1,
alignItems: 'stretch'
},
header: {
flex: 1
},
footer: {
flex: 1
},
timerWrapper: {
flex: 5,
justifyContent: 'center',
alignItems: 'center'
},
buttonWrapper: {
flex: 3,
flexDirection: 'row',
justifyContent: 'space-around',
alignItems: 'center'
}
});
AppRegistry.registerComponent('stopwatch',() => StopWatch);
答
试试这个。在onPress
startStopButton: function() {
return <TouchableHighlight underlayColor="gray" onPress={this.handleStartPress}>
<Text>
Start
</Text>
</TouchableHighlight>
},
@ neatoh80欢迎
错字错误..........! –