【问题标题】:Issue with react native lightbox library反应原生灯箱库的问题
【发布时间】:2017-01-29 13:40:25
【问题描述】:

我正在使用react-native-lightbox。我无法解决图书馆的两个问题。

  1. 道具类型失败:道具“onRequestClose”在“模态”中标记为必需,但其值为“未定义”。如何删除警告?

  2. 如何在中心显示图像?如图所示,它显示在侧面。

代码如下:

  export default class LightBoxImage extends Component {

    render() {
      return (
        <View>
          <Lightbox underlayColor="white">
            <Image
              source={{uri: data.url}}
            />
          </Lightbox>
        </View>
      );
    }
  }

【问题讨论】:

    标签: react-native react-native-lightbox


    【解决方案1】:

    要删除 onRequestClose 警告,您应该将其作为组件 Lightbox 的属性提供:

    import _ from 'lodash';
    ...
    <Lightbox onRequestClose={_.noop}>
    

    关于居中图像,将Image 组件包装在View 中,具有以下样式:

    flex: 1,
    alignItems: 'center',
    justifyContent: 'center'
    

    它应该可以工作

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-26
      • 1970-01-01
      • 2014-05-10
      • 1970-01-01
      • 2012-03-13
      • 2010-10-15
      • 2021-02-22
      相关资源
      最近更新 更多