oc 与 js交互之vue.js

  • 时间:
  • 浏览:0

    NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage];

@interface HDSpecialView ()

{

//  Created by peter.zhang on 2017/11/20.

    dispatch_async(dispatch_get_main_queue(), ^{

    return YES;

- (void)webViewDidFinishLoad:(UIWebView *)webView

    [self.webView stringByEvaluatingJavaScriptFromString:@"localStorage.clear();"];

- (instancetype)initWithFrame:(CGRect)frame withViewController:(UIViewController *)viewController{

    //去除长按后突然出现的文本选用框  

@property (nonatomic, weak) JSContext *jsContext;

}

{

    JSValue *Callback = self.jsContext[@"mobileChangeContent"];

#else

在webViewDidFinishLoad 代理法律办法中调用,之后 这人 之后 vue的所有的组件节点都之后 渲染

    model.vc = self.viewController;

{

    NSString *str=nil;

    self.jsContext[@"mobileObject"] = model;

//  headhunter

{

//初始化

        if (specialId&&![specialId isEqualToString:@""]) {

//

    NSURL *url=[NSURL URLWithString:str];

- (void)cleanCacheAndCookie

        NSLog(@"异常信息:%@", exceptionValue);

        [self initWebView];

    NSURLCache * cache = [NSURLCache sharedURLCache];

}

- (instancetype)initWithFrame:(CGRect)frame withViewController:(UIViewController *)viewController;

    }

    //正式环境

- (void)webViewDidFinishLoad:(UIWebView *)webView

//  HDSpecialViewController.h

    };

    //清除cookies

       }

    [Callback callWithArguments:@[@"4"]];

     window.mobileChangeContent = this.mobileChangeContent;

@interface HDSpecialView:UIView <UIWebViewDelegate>

@protocol specialJavaScriptDelegate <JSExport>

#import "HDHotSearchViewController.h"

   mobileChangeContent(level){

-(void)initWebView

@implementation SpecialJsModel

}

mounted(){

    //测试环境

    str=@"https://xxxxxxxxxxxxx/special.html#/";

        }

@property (strong, nonatomic) NSString *urlString;

    self = [super initWithFrame:frame];

#import <JavaScriptCore/JavaScriptCore.h>

        self.jsContext = [[JSContext alloc] init];

#import "WebViewController.h"

随意在组件中都要特殊除理,让组件的法律办法挂载到window的mobileChangeContent法律办法上

            vc.adver = adver;

@property (nonatomic,strong) UIViewController *vc;

    [MBProgressHUD hideHUDInView:self.viewController.view];

- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType

    //传值给web端

    SpecialJsModel *model  = [[SpecialJsModel alloc] init];

//

            adver.pictureId = [specialId longLongValue];

-(void)setUrlString:(NSString *)urlString

- (void)call{

    return self;

}

//  Created by peter.zhang on 2017/11/20.

@end

//  Copyright © 2017年 HunterOn. All rights reserved.

       if(level){

//

    self.jsContext.exceptionHandler = ^(JSContext *context, JSValue *exceptionValue) {

{

    myWebView.backgroundColor = kColor_BackGround;

    [cache setMemoryCapacity:0];

}

-(void)goToSpecial:(NSString *)specialId type:(NSString *)type

#ifdef __DEBUG

        self.backgroundColor =[UIColor whiteColor];

    _urlString =urlString;

    {

@property (strong, nonatomic) UIWebView *webView;

    for (cookie in [storage cookies])

    [webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.style.webkitUserSelect='none';"];  

}

    [cache removeAllCachedResponses];

//  headhunter

    self.title = [webView stringByEvaluatingJavaScriptFromString:@"document.title"];

//

    // 之后 在回调js的法律办法Callback把内容传出去

@interface SpecialJsModel : NSObject <specialJavaScriptDelegate>

-(void)goToSpecial:(NSString *)specialId type:(NSString *)type;

    [self cleanCacheAndCookie];

    myWebView.delegate =self;

   //实现移动端法律办法

.m文件

    [cache setDiskCapacity:0];

#endif

{

1、注意他们都他们都 都知道调用vue的法律办法的之后 要挂载到window上的法律办法

            adver.type = [type longLongValue];

            HDHotSearchViewController * vc = [[HDHotSearchViewController alloc]init];

},

组件A

    self.jsContext = [webView valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"];

@implementation HDSpecialView

-(void)clearCacheAndCookie

}

            [self.vc.navigationController pushViewController:vc animated:YES];

}

    model.jsContext = self.jsContext;

    [myWebView loadRequest:[NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval:120]];

vue中的实现mobileChangeContent(参数)的法律办法

/**清除缓存和cookie*/

    [self addSubview:myWebView];

@end

    //清除UIWebView的缓存

            Adver *adver = [[Adver alloc]init];

    self.jsContext = [webView valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"];

@end

        [storage deleteCookie:cookie];

}

//  Copyright © 2017年 HunterOn. All rights reserved.

        self.viewController = viewController;

//

    });

    str=@"https://xxxxxxxxxxxxx/special.html#/";

@property (nonatomic,strong) UIViewController * viewController;

}

//JS调用此法律办法进入高端专场

{

    NSHTTPCookie *cookie;

@end

    //该法律办法是vue中组件的法律办法

二、oc调用vue.js 组件的法律办法

    self.webView=myWebView;

- (void)clearCacheAndCookie;

}

{

        context.exception = exceptionValue;

@end

    }

//

@property (nonatomic, strong) JSContext *jsContext;

#import "HDSpecialView.h"

    if (self) {

    }

    model.webView = self.webView;

methods: {

@end

//清空缓存

    UIWebView *myWebView=[[UIWebView alloc] initWithFrame:CGRectMake(0, 0,kScreen_Width,kScreen_Height-kHeight_NavBar - kHeight_TabBar)];

@property (nonatomic, weak) UIWebView *webView;

    _urlString=request.URL.absoluteString;

    [self call];

//  HDSpecialViewController.m