javascript - 如何使用 ReactNative WebView 组件在我的 Android 应用程序中显示网页的特定部分?
问题描述
我想在我的 android 应用程序中使用 ReactNative webView 组件并只显示网页的特定部分。例如我想在下图中显示红色矩形指定的内容:
我不需要网页的其他部分。我可以通过以下代码显示整个页面:
<WebView
source={{ uri: https://github.com/TrySound }}
style={{ marginTop: 20 }}
/>
但不知道如何只显示红色矩形中的内容。有人可以帮我解决这个问题吗?
解决方案
WebView 不适用于您的情况。Github 确实有一个 RESTful API。您可以对用户名发出 GET 请求。您将收到一个 JSON 对象,并且您想要的信息将在 bio 下。
https://developer.github.com/v3/users/#get-a-single-user
您可以使用 fetch api 获取您的简历
function getBio(){
return fetch('https://api.github.com/users/trysound')
.then(function(response) { return response.json();})
.then(function(data) {return data.bio;});
}
并访问 api 请求的结果,您可以执行以下操作
getBio().then(function(bio){
// insert your code here to handle the string for your bio on github
console.log(bio);
});
推荐阅读
- excel - VBA如何将图像文件路径作为超链接提交到数据库
- angular - 使用 ngDoCheck 的成本是多少?
- python-3.x - 模块“matplotlib”没有属性“艺术家”,Matplotlib 3.0.0
- ios - 从 Swift 的 TimeInterval 中删除时间组件?
- python - 在用于图像分类的大型数据集上训练和测试精度没有希望
- python - Google Authenticator 的密钥是否应该保密?
- python - Django REST Framework:创建用户不需要密码,发送时密码不保存
- vb.net - 为测验的一组按钮添加分数
- themes - 为什么我的 powerlevel9k 提示中出现“cherry-or-revert”?
- javascript - 标记而不是删除死代码