上传者: 42134094
|
上传时间: 2021-11-16 16:57:06
|
文件大小: 60KB
|
文件类型: -
SwiftJS桥
SwiftJSBridge是一个方便JavaScript桥,用Swift编写,支持WKWebView和UIWebView
例子
Swift
let JSBridge = SwiftJSBridge ( for : webview)
JSBridge. addSwift ( bridge : { (data, cb) in
cb ? ([ " appVersion " : " 1.0 " ])
}, name : " getAppVersion " )
JSBridge ? . callJS ( name : " sendMessageToJS " , data : [ " message " : " Hi, I am native " ]) { (data) in
}
JS
function setupSwiftJSBridge ( callb