wkwebview 的跨域校验更为严格,增加如下配置即可
WKWebViewConfiguration* configuration = [self createConfigurationFromSettings:settings];
configuration.userContentController = userContentController;
configuration.userContentController = userContentController;
configuration.preferences.javaScriptEnabled = YES;
configuration.preferences.javaScriptCanOpenWindowsAutomatically = YES;
configuration.suppressesIncrementalRendering = YES; // 是否支持记忆读取
[configuration.preferences setValue:@YES forKey:@"allowFileAccessFromFileURLs"];
if (@available(iOS 10.0, *)) {
[configuration setValue:@YES forKey:@"allowUniversalAccessFromFileURLs"];
}
WKWebView * w = (WKWebView *)self.webViewEngine;
NSLog(@"%@",w.configuration.preferences);
[w.configuration.preferences setValue:@YES forKey:@"javaScriptEnabled"];
[w.configuration.preferences setValue:@YES forKey:@"allowFileAccessFromFileURLs"];