WKWebView xmlhttprequest with file url

后端 未结 3 853
一向
一向 2021-02-14 17:12

I am migrating from UIWebView to WKWebView with my local HTMLs in the app documents folder. I can load the index page with all css and js files, but every ajax call (xmlhttprequ

3条回答
  •  花落未央
    2021-02-14 17:39

    This solved my problem:

    let config = WKWebViewConfiguration()
    config.userContentController = contentController
    config.preferences.setValue(true, forKey: "allowFileAccessFromFileURLs")
    webView = WKWebView(frame: .zero, configuration: config)
    webView.uiDelegate = self
    webView.navigationDelegate = self
    view = webView
    

提交回复
热议问题