99re热这里只有精品视频,7777色鬼xxxx欧美色妇,国产成人精品一区二三区在线观看,内射爽无广熟女亚洲,精品人妻av一区二区三区

Weex 創(chuàng)建一個 Weex 實例

2023-12-27 15:58 更新

你既可以在全頁面中使用 Weex,也可以在一個 view 中渲染 Weex。只需要創(chuàng)建一個 Weex 實例并指定好回調(diào)方法,提供一個合法的 URL 就可以了。在 ?onCreate? 回調(diào)方法中將根 view 添加到你想顯示內(nèi)容的地方,并通過? instance.frame =? 來設(shè)置它的尺寸和位置。

#import <WeexSDK/WXSDKInstance.h>

- (void)viewDidLoad
{
    [super viewDidLoad];
    _instance = [[WXSDKInstance alloc] init];
    _instance.viewController = self;
    _instance.frame = self.view.frame;
    __weak typeof(self) weakSelf = self;
    _instance.onCreate = ^(UIView *view) {
        [weakSelf.weexView removeFromSuperview];
        weakSelf.weexView = view;
        [weakSelf.view addSubview:view];
    };
    _instance.onFailed = ^(NSError *error) {
        //process failure, you could open an h5 web page instead or just show the error.
    };
    _instance.renderFinish = ^ (UIView *view) {
        //process renderFinish
    };
    NSURL *url = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"js"];
    [_instance renderWithURL:url options:@{@"bundleUrl":[self.url absoluteString]} data:nil];
}


以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號