Go back
Home
  • Swift
    • 使用snapkit实现简单的动画
    • NSClassFromString替代方法
    • 加载gif图片
    • objectmapper:EnumTransform
      • RxSwift
        • RxSwift:(三)常用的操作符-Observable合并
        • RxSwift:(三)常用的操作符
        • RxSwift:(一)概念理解
        • RxSwift: Resource Trace
        • RxSwift:(二)TODO demo项目总结
      • 3rd
        • Alamofire
        • Moya
      • arcgis-basic
        • arcgis iOS SDK Tutorials(一)
        • 基础(二):Features and graphics
        • arcgis iOS SDK 安装集成
        • 基础(四):Spatial references
        • 基础(三):symbols and renderers
        • 基础(一):Layer types
      • arcgis-dev
        • 绘制点、线、面,以及使用callout
      • wkwebview
        • wkwebview本地url拼接参数的正确姿势
        • Swift与jscontext的交互
        • WKUIDelegate
        • wkwebview跨域问题
        • WKWebView与js交互
      • arcgis
        • (一)构建地图
        • (三)Display information
        • (二)Layer types
      • 奇淫巧技
        • 实现类似前端的async、await方法
      • 语法
        • ==和===区别
        • ObjectIdentifier
        • 元组
        • 使用CanImport检查模块是否可用
        • DiscardableResult
        • Let in Protocal
        • 字符串分割(sperateByCharacterSet)
        • 带有私有设置方法的公有属性
        • 遍历枚举值(CaseIterable)

wkwebview跨域问题

April 20, 2018
Swift

2018042018772a.png

访问本地资源file://设置:

wkwebView!.configuration.preferences.setValue(true, forKey: "allowFileAccessFromFileURLs")

//update 2018-06-14

跨域需要服务器的响应头设置Access-control

2018061444522x.png

需要额外注意的是,如果有自定义的header字段,需要加到Access-control-Allow-header里面。 参考https://blog.csdn.net/xuedapeng/article/details/79076704