iOS与vue交互(OC传值到Vue.js)
1、原生调用vue.js 某个vue组件下的方法。methods:{hwajax:function (strings) {this.tokenString=strings;}}mounted:function () {window.hwajax ...
·
1、原生调用vue.js 某个vue组件下的方法。
methods:{
hwajax:function (strings) {
this.tokenString=strings;
}
}
mounted:function () {
window.hwajax = this.hwajax;
}
// 页面加载完成之后调用在iOS里面调用js方法:
- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation {
NSString *jsStr = @"hwajax('lvkaike')";
NSLog(@"%@",jsStr);
[webView evaluateJavaScript:jsStr completionHandler:^(id _Nullable d, NSError * _Nullable error) {
NSLog(@"%@",d);
NSLog(@"%@",error);
}];
}
更多推荐
已为社区贡献8条内容
所有评论(0)