JSContext script syntax detection

28 Views Asked by At

Example

async function test(){ 
      ErrorCode
};
await test()

When I execute the script using JSContext, the syntax problem of the script cannot be detected

WKWebView *webView = [[WKWebView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
    [webView callAsyncJavaScript:@"async function test(){ ErrorCode};await test()" arguments:NULL inFrame:WKFrameInfo.new inContentWorld:WKContentWorld.defaultClientWorld completionHandler:^(id _Nullable_result, NSError * _Nullable error) {
        NSLog(@"evalute javascript error %@",error.description);
    }];
    [self.view addSubview:webView];

When I execute the script using WKWebView, I will get an error Can't find variable: ErrorCode

But WKWebView doesn't support injecting JSExport, how can I do it

0

There are 0 best solutions below