Javascript 如何使用ReactNative WebView组件在Android应用程序中显示网页的特定部分?
我想在android应用程序中使用ReactNative webView组件,只显示网页的特定部分。例如,我想在下图中显示红色矩形指定的内容: 我不需要网页的其他部分。 我可以通过下面的代码显示整个页面:Javascript 如何使用ReactNative WebView组件在Android应用程序中显示网页的特定部分?,javascript,android,react-native,webview,react-native-android,Javascript,Android,React Native,Webview,React Native Android,我想在android应用程序中使用ReactNative webView组件,只显示网页的特定部分。例如,我想在下图中显示红色矩形指定的内容: 我不需要网页的其他部分。 我可以通过下面的代码显示整个页面: <WebView source={{ uri: https://github.com/TrySound }} style={{ marginTop: 20 }} /> 但我不知道如何只显示红色矩形中的内容。有人能帮我解决这个问题吗?在你的情况下,WebView不起作
<WebView
source={{ uri: https://github.com/TrySound }}
style={{ marginTop: 20 }}
/>
但我不知道如何只显示红色矩形中的内容。有人能帮我解决这个问题吗?在你的情况下,WebView不起作用。Github确实有一个RESTful API。您可以请求获取用户名。您将收到一个JSON对象,所需信息将在bio下 您可以使用fetchapi获取您的bio
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);
});