WKWebView 解决跨域问题

    WKUserContentController *userContentController = [[WKUserContentController alloc] init];
    [self registerAllJavascriptWithUserContent:userContentController];
    WKWebViewConfiguration *config = [[WKWebViewConfiguration alloc] init];
    config.userContentController = userContentController;
    config.preferences.javaScriptEnabled = YES;
    config.preferences.javaScriptCanOpenWindowsAutomatically = YES;
    config.suppressesIncrementalRendering = YES; // 是否支持记忆读取
   [config.preferences setValue:@YES forKey:@"allowFileAccessFromFileURLs"];
    if (@available(iOS 10.0, *)) {
         [config setValue:@YES forKey:@"allowUniversalAccessFromFileURLs"];
    }

你可能感兴趣的:(WKWebView 解决跨域问题)