我无法使用100属性配置模式高度和宽度.有没有其他方法来设置模态高度和宽度?

 <Modal style={{height: 300, width: 300}}
        visible={this.state.isVisible}
        onRequestClose={this.closeModal}>
 </Modal>

上面的代码不起作用.

推荐答案

根据Modal份文件,没有要设置的styleprops .

您可以try 在<Modal>中设置<View>个尺寸:

<Modal transparent={true}
       visible={this.state.isVisible}
       onRequestClose={this.closeModal}>
  <View style={{
          flex: 1,
          flexDirection: 'column',
          justifyContent: 'center',
          alignItems: 'center'}}>
    <View style={{
            width: 300,
            height: 300}}>
      ...
    </View>
  </View>
</Modal>

React-native相关问答推荐

我们如何才能将我们自己的应用程序(IOS)排除在共享表中?

'未能找到 React 根视图的片段' React Native Android RNScreens

RNMK - 超级表达式必须为空或函数

Jest 遇到了带有 react-native 的意外令牌

变量 window在react-native 中代表什么?

滚动到具有可变元素大小的 FlatList 中的某些索引的有效方法

TabNavigator 中的 React Navigation 传递props

如何在react-native 中处理不同的屏幕尺寸?

React Navigation TabNavigator:在选项卡更改时重置上一个选项卡

xcode 8.3 框架未找到架构 armv7 的 FileProvider

你如何从 React Native 的 EventEmitter 实例中移除一个监听器?

React Native + Jest EMFILE:too many open files error

如何将本地文本文件加载到 React Native Project 中的字符串变量中?

是否可以在 react-native 的构造函数中调用异步函数?

Ipad 上的 React Native - 错误 - could not connect to development server

如何在react-native矢量图标中从多个文件导入图标?

horizontal水平 FlatList 前后的间距

如何在react-native中绘制虚线边框样式

Expo在使用Windows 10的android模拟器上运行

移动应用程序不需要 CORS?