【问题标题】:ScrollView child layout must be applied through the contentContainerStyle propScrollView 子布局必须通过 contentContainerStyle 属性应用
【发布时间】:2018-02-12 10:18:08
【问题描述】:

我正在使用 react native swiper。这个错误显示我不知道为什么。如何解决?在过去,没有这样的问题。这是第一次发生。怎么了?

这是一个完整错误的图像:

<Swiper loop={false}
          index={0}
          style={styles.wrapper}
          activeDotColor={'#EEE'}>

          <View style={styles.slide1}>
            <Text style={styles.text}>Choose category you like</Text>
          </View>
          <View style={styles.slide2}>
            <Text style={styles.text}>Bookmark articles that you</Text>
            <Text style={styles.text}>like</Text>
          </View>
          <View style={styles.slide3}>
            <Text style={styles.text}>Get notifications about your</Text>
            <Text style={styles.text}>chosen topic</Text>
            <Button style={styles.text} onPress={() => this.props.navigation.navigate("Home")}>
              <Text style={styles.text}>Main Screen</Text>
            </Button>
          </View>
        </Swiper>
      )
    } else {
      return <View></View>
    }
  }
}

const styles = {
  wrapper: {
    justifyContent: 'center',
    alignItems: 'center'
  },
  slide1: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#9DD6EB'
  },
  slide2: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#97CAE5'
  },
  slide3: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#92BBD9'
  },
  text: {
    alignSelf: 'center',
    color: '#FFF',
    fontSize: 26,
    fontWeight: 'bold'
  },
}

export default WelcomeScreen

请帮忙解决这个烦人的问题。

【问题讨论】:

    标签: javascript reactjs react-native react-native-android react-native-ios


    【解决方案1】:

    像这样添加样式

    <Swiper loop={false}
              index={0}
              contentContainerStyle={styles.wrapper}
              activeDotColor={'#EEE'}>
    

    【讨论】:

      【解决方案2】:

      使用contentContainerStyle 道具而不是style 道具。

      contentContainerStyle={styles.wrapper}
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2019-03-24
        • 2013-08-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-07-03
        相关资源
        最近更新 更多