首页 > 解决方案 > React Native WebView 不工作 IOS 模拟器

问题描述

WebView 可以在 IOS 模拟器中工作吗?

下面的代码不会返回错误,也不会显示任何内容。

import React, { Component } from 'react';
import { WebView } from 'react-native';

class MyTest extends Component {
  render() {
    return (
      <WebView
        source={{uri: 'https://github.com/facebook/react-native'}}
        style={{marginTop: 20}}
      />
    );
  }
}

export default MyTest;

谢谢

标签: react-nativewebview

解决方案


WebView 在我的模拟器中运行良好。我的代码:

<WebView 
useWebKit={true} 
style={{flex:1}} 
source={{uri:url}} 
startInLoadingState={true} 
renderLoading={()=>(<ActivityIndicator size='large' color={COLOR_STANDARD} 
style={{marginTop:100}} />)}>
</WebView> 

推荐阅读