Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/208.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何使用ReactNative WebView组件在Android应用程序中显示网页的特定部分?_Javascript_Android_React Native_Webview_React Native Android - Fatal编程技术网

Javascript 如何使用ReactNative WebView组件在Android应用程序中显示网页的特定部分?

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不起作

我想在android应用程序中使用ReactNative 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);
});