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);
    }];
}
Logo

前往低代码交流专区

更多推荐