oc 与 js交互之vue.js

  • 时间:
  • 浏览:1

    [cache removeAllCachedResponses];

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

    }

    [MBProgressHUD hideHUDInView:self.viewController.view];

@end

@property (nonatomic,strong) UIViewController *vc;

{

}

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

        context.exception = exceptionValue;

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

    }

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

    [cache setDiskCapacity:0];

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

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

    //传值给web端

   mobileChangeContent(level){

@end

- (void)cleanCacheAndCookie

#import "WebViewController.h"

    self = [super initWithFrame:frame];

在webViewDidFinishLoad 代理措施 中调用,不可能 这个 完后 vue的所有的组件节点都不可能 渲染

@implementation HDSpecialView

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

@property (nonatomic, weak) JSContext *jsContext;

}

    model.vc = self.viewController;

//

    [cache setMemoryCapacity:0];

}

{

@end

    //测试环境

    myWebView.delegate =self;

    });

    return YES;

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

@property (nonatomic, strong) JSContext *jsContext;

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

组件A

        self.viewController = viewController;

@end

//

    model.jsContext = self.jsContext;

#import <JavaScriptCore/JavaScriptCore.h>

@property (strong, nonatomic) NSString *urlString;

{

#import "HDSpecialView.h"

//初始化

- (void)call{

#ifdef __DEBUG

    [self addSubview:myWebView];

{

#import "HDHotSearchViewController.h"

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

        [self initWebView];

- (void)webViewDidFinishLoad:(UIWebView *)webView

@protocol specialJavaScriptDelegate <JSExport>

//  headhunter

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

//  HDSpecialViewController.m

    dispatch_async(dispatch_get_main_queue(), ^{

@property (strong, nonatomic) UIWebView *webView;

    self.webView=myWebView;

   //实现移动端措施

mounted(){

}

    for (cookie in [storage cookies])

            adver.type = [type longLongValue];

二、oc调用vue.js 组件的措施

- (void)webViewDidFinishLoad:(UIWebView *)webView

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

    _urlString =urlString;

    return self;

}

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

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

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

    //该措施 是vue中组件的措施

    myWebView.backgroundColor = kColor_BackGround;

#else

    NSHTTPCookie *cookie;

@interface HDSpecialView:UIView <UIWebViewDelegate>

//  HDSpecialViewController.h

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

    // 完后 在回调js的措施 Callback把内容传出去

@end

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

}

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

            vc.adver = adver;

//

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

@end

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

    NSString *str=nil;

//

    //清除cookies

},

        }

//

随意在组件中时要特殊补救,让组件的措施 挂载到window的mobileChangeContent措施 上

        [storage deleteCookie:cookie];

    if (self) {

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

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

    _urlString=request.URL.absoluteString;

/**清除缓存和cookie*/

- (void)clearCacheAndCookie;

//  headhunter

    NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage];

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

    //清除UIWebView的缓存

@implementation SpecialJsModel

       if(level){

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

}

            adver.pictureId = [specialId longLongValue];

    //去除长按后经常出现的文本选折 框  

}

}

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

{

        self.backgroundColor =[UIColor whiteColor];

@interface SpecialJsModel : NSObject <specialJavaScriptDelegate>

-(void)setUrlString:(NSString *)urlString

    [self cleanCacheAndCookie];

{

}

    }

@property (nonatomic,strong) UIViewController * viewController;

vue中的实现mobileChangeContent(参数)的措施

//JS调用此措施 进入高端专场

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

    //正式环境

    };

    NSURL *url=[NSURL URLWithString:str];

{

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

//

-(void)initWebView

}

//清空缓存

    NSURLCache * cache = [NSURLCache sharedURLCache];

@interface HDSpecialView ()

-(void)clearCacheAndCookie

    {

       }

     window.mobileChangeContent = this.mobileChangeContent;

#endif

{

@property (nonatomic, weak) UIWebView *webView;

.m文件

methods: {

1、注意大伙儿都知道调用vue的措施 的完后 要挂载到window上的措施

    model.webView = self.webView;

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

    [self call];

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