evaluateJavaScript() with Error Domain=NSCocoaErrorDomain Code=3840 就在 iPhone 5 - iOS 10.3.3

evaluateJavaScript() with Error Domain=NSCocoaErrorDomain Code=3840 just on iPhone 5 - iOS 10.3.3

我想要 ti evaluateJavaScript(),它是 WKWebView 的一个函数 我得到的错误详细信息是:

Error Domain=NSCocoaErrorDomain Code=3840 "JSON text did not start with array or object and option to allow fragments not set." UserInfo={NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.}

有人遇到过这个问题吗?希望你的share.Thanks!

您可以查看JavaScript核心框架来评估JavaScript。它是原生 iOS 框架。

let context = JSContext()

let _ = context?.evaluateScript(evaluateScriptJSCode)

let method = context?.objectForKeyedSubscript("methodToCallInJavaScript")

let result = method?.call(withArguments: [params])