【问题标题】:Why is the modal view not appearing for mobile browser?为什么移动浏览器不显示模态视图?
【发布时间】:2020-11-08 13:37:02
【问题描述】:

我正在使用 React 原生网络,我有一个模态视图,如下所示:

(我只引用返回部分,因为它主要是与设计相关的问题)

<View style={{flex: 1, alignItems: 'center', justifyContent: 'center'}}>
  <View>
    <View
      style={{
        flex: 1,
        justifyContent: 'center',
        alignItems: 'center',
      }}>
      <View
        style={{
          backgroundColor: 'white',
          height: '400px',
          width: '450px',
        }}>
        <Text
          style={{
            fontFamily: 'Roboto',
            fontWeight: 'bold',
            fontSize: 18,
            textAlign: 'center',
            padding: 20,
          }}>
          {name}
        </Text>
        <View
          style={{
            borderBottomColor: '#18D0E4',
            borderBottomWidth: 1,
          }}
        />
        <View
          style={{
            flexDirection: 'row',
            justifyContent: 'space-between',
            marginTop: '5%',
            padding: 20,
            margin: '5%',
          }}>
          {reminder == 6 && toggle == 6 ? (
            <TouchableOpacity style={{flexDirection: 'row'}}>
              <Image
                source={Images.circle}
                style={{
                  height: 15,
                  width: 15,
                  marginTop: '2%',
                  paddingRight: '1%',
                }}
              />
              <Text
                style={{
                  fontFamily: 'Roboto',
                  fontSize: 17,
                  color: '#000',
                  marginLeft: 5,
                }}>
                Set Different reminder
              </Text>
            </TouchableOpacity>
          ) : (
            <TouchableOpacity
              style={{flexDirection: 'row'}}
              onPress={() => reminderSet()}>
              <Image
                source={Images.circle_o}
                style={{
                  height: 15,
                  width: 15,
                  marginTop: '2%',
                  paddingRight: '1%',
                }}
              />
              <Text
                style={{
                  fontFamily: 'Roboto',
                  fontSize: 17,
                  marginLeft: 5,
                  color: '#000',
                }}>
                Set Different reminder
              </Text>
            </TouchableOpacity>
          )}
          {vaccinatedOn == 1 && toggle == 1 ? (
            <TouchableOpacity style={{flexDirection: 'row'}}>
              <Image
                source={Images.circle}
                style={{
                  height: 15,
                  width: 15,
                  marginTop: '2%',
                  // paddingRight: '1%',
                }}
              />
              <Text
                style={{
                  fontFamily: 'Roboto',
                  fontSize: 17,
                  marginLeft: 5,
                  color: '#000',
                }}>
                Vaccinated on
              </Text>
            </TouchableOpacity>
          ) : (
            <TouchableOpacity
              style={{flexDirection: 'row'}}
              onPress={() => vaccinationSet()}>
              <Image
                source={Images.circle_o}
                style={{
                  height: 15,
                  width: 15,
                  marginTop: '2%',
                  // paddingRight: '1%',
                }}
              />
              <Text
                style={{
                  fontFamily: 'Roboto',
                  fontSize: 17,
                  marginLeft: 5,
                  color: '#000',
                }}>
                Vaccinated on
              </Text>
            </TouchableOpacity>
          )}
        </View>
        <View
          style={{
            justifyContent: 'center',
            alignItems: 'center',
          }}>
          <DatePicker selected={date} onChange={(date) => setDate(date)} />
        </View>
      </View>
    </View>
    <View
      style={{
        flexDirection: 'row',
        backgroundColor: '#fff',
        alignItems: 'center',
        justifyContent: 'center',
        width: '82%',
        paddingTop: 20,
      }}>
      <TouchableOpacity
        style={{
          flex: 1,
          borderTopColor: '#C0C0C0',
          borderTopWidth: 1,
          borderRightColor: '#C0C0C0',
          borderRightWidth: 1,
          justifyContent: 'center',
          alignItems: 'center',
          padding: 10,
        }}
        onPress={() => navigation.goBack()}>
        <Text
          style={{
            fontFamily: 'Roboto',
            fontSize: 17,
            fontWeight: 'bold',
            color: '#000',
          }}>
          Cancel
        </Text>
      </TouchableOpacity>
      <TouchableOpacity
        style={{
          flex: 1,
          borderTopColor: '#C0C0C0',
          borderTopWidth: 1,
          borderLeftColor: '#C0C0C0',
          borderLeftWidth: 1,
          justifyContent: 'center',
          alignItems: 'center',
          padding: 10,
        }}
        onPress={() => SaveData(id)}>
        <Text
          style={{
            fontFamily: 'Roboto',
            fontSize: 17,
            fontWeight: 'bold',
            color: '#000',
          }}>
          OK
        </Text>
      </TouchableOpacity>
    </View>
  </View>
</View>

web 视图显示如下:

但是,一旦我切换到移动视图,模式就会消失,如下所示:

请告诉我,我哪里出错了,任何线索将不胜感激,提前谢谢你。

如果还需要什么,请告诉我。

【问题讨论】:

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


    【解决方案1】:

    &lt;View style={{ height: "100vh", width: "100vw" }}&gt; 应添加到 Root 以使其在所有平台上都能响应

    【讨论】:

      猜你喜欢
      • 2013-03-15
      • 1970-01-01
      • 2015-04-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多