【发布时间】:2019-04-01 18:14:45
【问题描述】:
我正在尝试在 webview 中运行本地 html 文件,但它没有加载完整的内容。
我在具有相同 html 文件的 Native 应用程序上对其进行了测试,它显示得很好。
我不确定是什么问题。
本机代码
@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}
/>
React Native 截图
原生截图
请帮帮我。
【问题讨论】:
标签: javascript google-maps react-native webview react-native-ios