我正在尝试使用react-native-webview(Android应用),并且在尝试加载我的网站时出现白屏: https://lostlaowai.app:4432/?ID=1105T140W4iUserAgentAllow3
我还注意到,如果没有https://和以/结尾,则WebView会加载https://www.google.com/,但不会加载google.com。 这可能有关吗?
在浏览器中运行它时效果很好。但是我无法将其加载到WebView中。过去几天,我读了各种各样的文章,描述了WebView白屏的类似问题,但是没有一种可行的解决方案...这是我的代码:
import React from 'react';
import {
SafeAreaView,
StyleSheet,
ScrollView,
View,
Text,
StatusBar,
Dimensions,
Alert
} from 'react-native';
import {
Header,
LearnMoreLinks,
Colors,
DebugInstructions,
ReloadInstructions,
} from 'react-native/Libraries/NewAppScreen';
import { WebView } from 'react-native-webview';
const App: () => React$Node = () => {
const deviceHeight = Dimensions.get('window').height;
const deviceWidth = Dimensions.get('window').width;
return (
<View style={{flex: 1}}>
<WebView
source={{ uri: 'https://lostlaowai.app:4432/?ID=1105T140W4iUserAgentAllow3' }}
onError={syntheticEvent => {
const { nativeEvent } = syntheticEvent;
Alert.alert('WebView error: ', "" + nativeEvent);
}}
onHttpError={syntheticEvent => {
const { nativeEvent } = syntheticEvent;
console.warn(
'WebView received error status code: ',
nativeEvent.statusCode,
);
}}
mixedContentMode={'always'}
geolocationEnabled={true}
ignoreSslError={true}
javaScriptEnabled={true}
domStorageEnabled={true}
scalesPageToFit={true}
startInLoadingState={false}
style={{flex: 1, width: deviceWidth, height: deviceHeight}}
/>
</View>
);
};
export default App;
我的规格:
react-native-cli:2.0.1
反应性:0.61.2
节点:v10.16.3
设备:小米Note
任何帮助将不胜感激!