gpt4 book ai didi

react-native - 将 SafeAreaView 与 react-native-webview 一起使用

转载 作者:行者123 更新时间:2023-12-03 23:27:59 26 4
gpt4 key购买 nike

我们如何使用 SafeAreaView为了显示 WebView ?我试过这种方式:

import React from 'react';
import {SafeAreaView, StatusBar} from 'react-native';
import {WebView} from 'react-native-webview';

class ChaineYT extends React.Component {

render() {
return (
<SafeAreaView>
<WebView
source={{uri: "someURL"}}
/>
</SafeAreaView>
)
}
}

export default ChaineYT


但它正在呈现一个白页。

谢谢

最佳答案

您没有指定 SafeAreaView 的高度和宽度。

更改 <SafeAreaView><SafeAreaView style={{ flex:1 }}>
官方documentation明确地说:

A component can only expand to fill available space if its parent has dimensions greater than 0. If a parent does not have either a fixed width and height or flex, the parent will have dimensions of 0 and the flex children will not be visible.

关于react-native - 将 SafeAreaView 与 react-native-webview 一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58589398/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com