Swift--如何清除WKWebView的缓存

let dataStore = WKWebsiteDataStore.default()
        dataStore.fetchDataRecords(ofTypes: WKWebsiteDataStore.allWebsiteDataTypes(), completionHandler: { (records) in
            for record in records{
                // 清除指定网站
                if record.displayName.contains("sina.com") {
                    WKWebsiteDataStore.default().removeData(ofTypes: record.dataTypes, for: [record], completionHandler: {
                        //清除成功
                        print("清除成功\(record)")
                    })
                }
            }
        })

你可能感兴趣的:(Swift--如何清除WKWebView的缓存)