oc 与 js交互之vue.js

  • 时间:
  • 浏览:0
  • 来源:彩神3D_神彩3D官方

@interface HDSpecialView ()

-(void)setUrlString:(NSString *)urlString

-(void)clearCacheAndCookie

@property (nonatomic, weak) UIWebView *webView;

    //去除长按后突然总出 的文本选折 框  

    NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage];

#import <JavaScriptCore/JavaScriptCore.h>

            adver.type = [type longLongValue];

.m文件

    myWebView.delegate =self;

@property (nonatomic, weak) JSContext *jsContext;

}

{

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

{

1、注意许多人 都知道调用vue的妙招的后来要挂载到window上的妙招

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

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

- (void)webViewDidFinishLoad:(UIWebView *)webView

}

#ifdef __DEBUG

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

    {

//

     window.mobileChangeContent = this.mobileChangeContent;

    _urlString=request.URL.absoluteString;

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

//  HDSpecialViewController.h

    //该妙招是vue中组件的妙招

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

}

#import "WebViewController.h"

    [MBProgressHUD hideHUDInView:self.viewController.view];

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

    self.webView=myWebView;

    };

@end

- (void)cleanCacheAndCookie

在webViewDidFinishLoad 代理妙招中调用,后来这种 后来vue的所有的组件节点都后来渲染

    NSString *str=nil;

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

    self = [super initWithFrame:frame];

@property (nonatomic, strong) JSContext *jsContext;

- (void)call{

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

    //清除UIWebView的缓存

    }

    model.webView = self.webView;

{

#endif

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

}

}

//  headhunter

{

        }

{

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

@property (strong, nonatomic) UIWebView *webView;

//清空缓存

@property (nonatomic,strong) UIViewController * viewController;

@end

}

    });

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

   //实现移动端妙招

}

@end

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

        [self initWebView];

    NSURLCache * cache = [NSURLCache sharedURLCache];

//初始化

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

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

@protocol specialJavaScriptDelegate <JSExport>

methods: {

@end

@implementation HDSpecialView

    _urlString =urlString;

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

组件A

    }

- (void)clearCacheAndCookie;

        self.viewController = viewController;

#import "HDHotSearchViewController.h"

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

    NSURL *url=[NSURL URLWithString:str];

vue中的实现mobileChangeContent(参数)的妙招

    [cache setDiskCapacity:0];

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

随意在组件中需要特殊补救,让组件的妙招挂载到window的mobileChangeContent妙招上

}

//  HDSpecialViewController.m

    [cache removeAllCachedResponses];

#else

        [storage deleteCookie:cookie];

   mobileChangeContent(level){

       if(level){

@end

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

#import "HDSpecialView.h"

-(void)initWebView

        context.exception = exceptionValue;

//

    [cache setMemoryCapacity:0];

},

    NSHTTPCookie *cookie;

- (void)webViewDidFinishLoad:(UIWebView *)webView

    [self cleanCacheAndCookie];

    [self addSubview:myWebView];

@property (nonatomic,strong) UIViewController *vc;

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

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

    //测试环境

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

/**清除缓存和cookie*/

}

    //传值给web端

//

    [self call];

//

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

    // 后来在回调js的妙招Callback把内容传出去

        self.backgroundColor =[UIColor whiteColor];

//  headhunter

    model.vc = self.viewController;

    dispatch_async(dispatch_get_main_queue(), ^{

    }

    model.jsContext = self.jsContext;

{

@interface SpecialJsModel : NSObject <specialJavaScriptDelegate>

            adver.pictureId = [specialId longLongValue];

    return YES;

    if (self) {

二、oc调用vue.js 组件的妙招

@interface HDSpecialView:UIView <UIWebViewDelegate>

    for (cookie in [storage cookies])

@implementation SpecialJsModel

    myWebView.backgroundColor = kColor_BackGround;

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

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

       }

}

@property (strong, nonatomic) NSString *urlString;

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

            vc.adver = adver;

}

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

//JS调用此妙招进入高端专场

//

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

{

    //清除cookies

{

//

@end

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

    //正式环境

mounted(){

    return self;