嵌套时React Native Button不起作用

时间:2018-11-18 15:15:05

标签: reactjs react-native react-native-button

刚开始使用react native时,我无法使按钮正常工作 按钮1正常工作 但按钮2嵌套且无法使用

``` 导入{   StyleSheet,   视图,   文本,   按钮   可触摸的高光 }来自“ react-native”; 从“ react-native-easy-grid”导入{Col,Row,Grid};

sayHi = from => {
    alert(from + " was clicked");
  };

  render() {
    return (
      <View style={styles.container}>
        <Button
          title="BUTTON 1"
          accessibilityLabel="THIS IS BUTTON 1"
          onPress={() => {
            this.sayHi("Button 1");
          }}
        />
        <Grid>
          <Col>
            <Text> col 1</Text>
            <TouchableHighlight
              style={{
                height: 40,
                width: 100
              }}
              onPress={() => {
                this.sayHi("highlight");
              }}
              underlayColor="red"
            >
              <Button
                title="BUTTON 2"
                accessibilityLabel="THIS IS BUTTON 2"
                onPress={() => {
                  this.sayHi("Button 2");
                }}
              />
            </TouchableHighlight>
          </Col>
          <Col>
          </Col>
        </Grid>
      </View>
    );

0 个答案:

没有答案