reactjs - WebView 未在反应本机应用程序中显示
问题描述
我正在处理本机反应的 webview。Webview 未显示。我已经为 webview 设置了代码。这是我也添加了样式的更新代码。在 webview 之后,我添加了 facebook 登录按钮。Webview 应该比 facebook 登录按钮先显示。但我没有在我的屏幕上看到 webview。
render() {
return (
<View style={styles.container}>
<Text>Show webview</Text>
<WebView
source = {{uri : 'google.com'}}
style={{
height: '100%',
width: '100%',
position: "absolute",
top: 20,
left: 0,
alignItems: "baseline",
bottom: 0,
right: 0
}}
/>
{this.state.avatar_url ?
<Image
source={{ uri: this.state.avatar_url }}
style={styles.imageStyle} /> : null}
<Text style={styles.text}> {this.state.user_name} </Text>
<LoginButton
readPermissions={['public_profile']}
onLoginFinished={(error, result) => {
if (error) {
console.log(error.message);
console.log('login has error: ' + result.error);
} else if (result.isCancelled) {
console.log('login is cancelled.');
} else {
AccessToken.getCurrentAccessToken().then(data => {
// result1 = await AuthUtils.loginFB();
console.log("ijrfu");
console.log(data.accessToken.toString());
Alert.alert(data.accessToken.toString());
const processRequest = new GraphRequest(
'/me?fields=name,picture.type(large)',
null,
this.get_Response_Info
);
// Start the graph request.
new GraphRequestManager().addRequest(processRequest).start();
});
}
}}
onLogoutFinished={this.onLogout}
/>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
},
text: {
fontSize: 20,
color: '#000',
textAlign: 'center',
padding: 20
},
imageStyle: {
width: 200,
height: 300,
resizeMode: 'contain'
}
});
解决方案
<View style={{ height: '100%', width: '100%' }}>
<Text>Show webview</Text>
<WebView
source={{ uri: 'https://www.google.com' }}
style={{ height: '100%',
width: '100%',
position: "absolute",
top: 20,
left: 0,
alignItems: "baseline",
bottom: 0,
right: 0}}
/>
</View>
推荐阅读
- php - 如何防止暴力登录到站点 - Laravel 5.7?
- mongodb - MongoDB 。处理数组和计算
- c++ - googletest 中的程序测试?
- asp.net - asp.net MVC 5 - 无法访问列表中的项目,在视图中
- botframework - 使用 MS Bot Framwork v4 提示用户在对话框流中上传文件
- android - 为所有屏幕尺寸精确设计活动
- php - 我如何检查缩略图 youtube api
- database - 如何找到 Postgres 集群上的所有数据库和相关模式?
- python - 关于如何解决无限循环问题的建议(python-pandas)
- javascript - Hook useReducer 分派 2 次