function view(id){
//alert(id);
myjs.passIdToApp(id);
// passIdApp(id);
}
< /script>
*******************************************************我是分割线****************************************************************
NSString *htmlPath=[[NSBundle mainBundle] resourcePath];
htmlPath=[htmlPath stringByAppendingPathComponent:@"Test.html"];
NSURL *localURL=[[NSURL alloc]initFileURLWithPath:htmlPath];
NSMutableURLRequest *request=[NSMutableURLRequest requestWithURL:localURL];
[self.mywebview loadRequest:request];
JSContext *context = [self.mywebview valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"];
context[@"myjs.passIdToApp"] = ^() {
NSLog(@"Begin Log");
NSArray *args = [JSContext currentArguments];
for (JSValue *jsVal in args) {
NSLog(@"%@", jsVal);
NSString *productID= [NSString stringWithFormat:@"%@",jsVal];
[self.navigationController pushViewController:[[Details_VC alloc]initWithProductID:productID] animated:YES];
}
// JSValue *this = [JSContext currentThis];
NSLog(@"-------End Log-------");
};
*******************************************************我还是分割线****************************************************************
如果只调用passIdApp(id);但是如果改成了myjs.passIdApp(id);就无法获取数据了
取消
评论