我试图在我的应用程序中实现react native webview组件,但web视图没有加载任何url,只是显示白色页面.

var React = require('react-native');
var{
 View,
 Text,
 StyleSheet,
 WebView
} = React;


module.exports = React.createClass({
 render: function(){
   return(
     <View style={styles.container}>
      <WebView source={{uri: 'https://m.facebook.com'}} style= {styles.webView}/>
     </View>
   );
 }
});

var styles = StyleSheet.create({
   container: {
     flex:1,
     backgroundColor:  '#ff00ff'
   },webView :{
     height: 320,
     width : 200
   }
});

下面是输出的屏幕截图.

推荐答案

下面是一段对我有用的代码.

render: function(){
   return(
     <View style={styles.container}>
      <WebView url={'https://m.facebook.com'} style= {styles.webView}/>
     </View>
   );
 }

React-native相关问答推荐

Reaction-原生NavBottom设计背景

Appcenter codepush 返回请求被阻止

错误:HostFunction 中的异常: Malformed calls from JS: field sizes are different. In an Animated View

如何在 React Native 中正确地将组件导入到我的导航器中?

如何在 Recompose 中使用 withHandlers 将 refs 添加到功能组件并在 ScrollView 上调用 ScrollTo?

在 create-react-native-app 元素中突然看到错误Plugin/Preset files are not allowed to export objects, only functions

Google SignIn SDK 因抛出错误而失败,发生不可恢复的登录失败 -catch 错误

React Native:约束 Animated.Value

如何在react-native android中打开应用程序设置页面?

如何使用 React Navigation 使 TabNavigator 按钮推送模态屏幕

React-Native:显示加载屏幕直到加载 webview

React-Native 构建失败的应用程序:mergeDebugAssets

元素中缺少main.jsbundle、Foundation和Security,导致报错

可以react native使用jQuery

如何在 React Native Android 中设置按钮的高度

仅链接字体的方法

如何在react-native中显示toast消息

键盘可见时无法单击按钮

如何将 jest 测试移动到 /test 文件夹并让它们运行?

在 React Native 中,两个等宽的按钮水平填充屏幕