Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.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 如何通过uri加载本地html_Javascript_Google Maps_React Native_Webview_React Native Ios - Fatal编程技术网

Javascript 如何通过uri加载本地html

Javascript 如何通过uri加载本地html,javascript,google-maps,react-native,webview,react-native-ios,Javascript,Google Maps,React Native,Webview,React Native Ios,我试图在webview中运行本地html文件,但它没有加载完整内容。 我用相同的html文件在本机应用程序上进行了测试,结果显示效果良好 我不确定是什么问题 本机代码 @IBOutlet weak var mapView: WKWebView! override func viewDidLoad() { super.viewDidLoad() mapView.uiDelegate = self; mapView.navigationDele

我试图在webview中运行本地html文件,但它没有加载完整内容。
我用相同的html文件在本机应用程序上进行了测试,结果显示效果良好

我不确定是什么问题

本机代码

@IBOutlet weak var mapView: WKWebView!
    override func viewDidLoad() {
        super.viewDidLoad()
        mapView.uiDelegate = self;
        mapView.navigationDelegate = self;
        let url = Bundle.main.url(forResource: "index", withExtension: "html")!
        mapView.loadFileURL(url, allowingReadAccessTo: url)
        let request = URLRequest(url: url)
        mapView.load(request)
    }
<WebView
          originWhitelist={['*']}
          onLoad={this.onLoad}
          source={Platform.OS === 'android' ? { uri: 'file:///android_asset/index.html' } : require('../ios/web/index.html')}
          dataDetectorTypes={'none'}
          ref='webview'
          onMessage={e => this.onMessage(JSON.parse(e.nativeEvent.data))}
          onShouldStartLoadWithRequest={this.onShouldStartLoadWithRequest}
          onNavigationStateChange={this.onShouldStartLoadWithRequest}
          injectedJavaScript={patchPostMessageJsCode}
          useWebKit={true}
          />
反应本机代码

@IBOutlet weak var mapView: WKWebView!
    override func viewDidLoad() {
        super.viewDidLoad()
        mapView.uiDelegate = self;
        mapView.navigationDelegate = self;
        let url = Bundle.main.url(forResource: "index", withExtension: "html")!
        mapView.loadFileURL(url, allowingReadAccessTo: url)
        let request = URLRequest(url: url)
        mapView.load(request)
    }
<WebView
          originWhitelist={['*']}
          onLoad={this.onLoad}
          source={Platform.OS === 'android' ? { uri: 'file:///android_asset/index.html' } : require('../ios/web/index.html')}
          dataDetectorTypes={'none'}
          ref='webview'
          onMessage={e => this.onMessage(JSON.parse(e.nativeEvent.data))}
          onShouldStartLoadWithRequest={this.onShouldStartLoadWithRequest}
          onNavigationStateChange={this.onShouldStartLoadWithRequest}
          injectedJavaScript={patchPostMessageJsCode}
          useWebKit={true}
          />
this.onMessage(JSON.parse(e.nativeEvent.data))}
onShouldStartLoadWithRequest={this.onShouldStartLoadWithRequest}
onNavigationStateChange={this.onShouldStartLoadWithRequest}
injectedJavaScript={patchPostMessageJsCode}
useWebKit={true}
/>
反应本机屏幕截图

本地屏幕截图


请帮助我。

尝试调整Web视图的大小,以便

import{Dimensions, SafeAreaView, WebView} from 'react-native';

<SafeAreaView style={{flex:1}}>

     <WebView
          originWhitelist={['*']}
          onLoad={this.onLoad}
          source={Platform.OS === 'android' ? { uri: 'file:///android_asset/index.html' } : require('../ios/web/index.html')}
          dataDetectorTypes={'none'}
          ref='webview'
          onMessage={e => this.onMessage(JSON.parse(e.nativeEvent.data))}
          onShouldStartLoadWithRequest={this.onShouldStartLoadWithRequest}
          onNavigationStateChange={this.onShouldStartLoadWithRequest}
          injectedJavaScript={patchPostMessageJsCode}
          useWebKit={true}
          style={{ height: Dimensions.get('window').width.height, width:Dimensions.get('window') , resizeMode: 'cover', flex: 1 }}
          />

</SafeAreaView>
从'react native'导入{Dimensions,SafeAreaView,WebView};
this.onMessage(JSON.parse(e.nativeEvent.data))}
onShouldStartLoadWithRequest={this.onShouldStartLoadWithRequest}
onNavigationStateChange={this.onShouldStartLoadWithRequest}
injectedJavaScript={patchPostMessageJsCode}
useWebKit={true}
style={{height:Dimensions.get('window').width.height,width:Dimensions.get('window'),resizeMode:'cover',flex:1}
/>

谢谢您的回复。你认为调整webview的大小可以解决问题吗?我不太确定。即使调整了大小,内容仍然无法完全加载?