【问题标题】:React Native ScrollView not working反应本机滚动视图不起作用
【发布时间】:2018-02-07 19:57:28
【问题描述】:

我是 React Native 的新手。我需要实现一个 ScrollView,但它根本不起作用。我向其中添加了多个组件,当我尝试滚动时,什么也没有发生,文本从我的屏幕中消失,我看不到它。代码如下:

    render() {
    return(
      <ScrollView 
        behaviour = "height"
        keyboardVerticalOffset = {64}
        contentContainerStyle = {{alignItems: 'center', marginTop: '5%', flex: 1}}
      >        
          <Title style={styles.title}>Booking Confirmation</Title>
          <Image style={{
            width: '55%',
            height: '5%',
            marginTop: '5%', 
            //flex : 0.2
            }}
            source={this.getCarrierImage(this.props.currentQuote.Carrier)}
            />
          <Text style = {{padding: '5%', fontWeight: 'bold'}}>Economy 2-3 days delivery</Text> 
          <Text style = {{textAlign: 'center'}}>Collection 8am-6pm, delivery in 2-3 working, delivered before 6pm</Text>

        <Text style = {{marginTop: '5%', fontWeight: 'bold', marginRight: '70%'}}>Parcel Details</Text>

        <ItemConfirmation/>

        <QuoteWarning/>
        <QuoteWarning/>
        <QuoteWarning/>
        <QuoteWarning/>
        <QuoteWarning/>
        <QuoteWarning/>
        <QuoteWarning/>
        <QuoteWarning/>
        <QuoteWarning/>
        <QuoteWarning/>
      </ScrollView>
     );
}

【问题讨论】:

    标签: javascript reactjs react-native scrollview


    【解决方案1】:

    据我所知,react-native 使用 flex 作为布局属性,它不采用您的百分比值。 尝试使用像素作为填充、边距、宽度和高度。你可能会更接近一点。当我在我的电脑旁时,可以在几个小时内更仔细地查找它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-11-03
      • 2020-04-19
      • 2018-08-21
      • 2021-08-12
      • 2019-10-25
      • 2022-09-30
      • 1970-01-01
      • 2018-08-28
      相关资源
      最近更新 更多