weex componet 簡單擴充套件

lqkin發表於2018-03-15

weex 呼叫componet 《template> 《div class="wrapper"> 《test class="test">《/test> 《/div> 《/template> 1.擴充套件步驟 建立類繼承WXComponent #import "WXComponent.h" #import <UIKit/UIKit.h> @interface LQComponent : WXComponent

@end 2.實現方法

  • (instancetype)initWithRef:(NSString *)ref type:(NSString *)type styles:(NSDictionary *)styles attributes:(NSDictionary *)attributes events:(NSArray *)events weexInstance:(WXSDKInstance *)weexInstance{

    self = [super initWithRef:ref type:type styles:styles attributes:attributes events:events weexInstance:weexInstance]; if (self) {

    } return self; }

  • (void)viewDidLoad{ //新增檢視 [super viewDidLoad]; _testView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 100, 100)]; _testView.backgroundColor = [UIColor redColor]; [self.view addSubview:_testView]; }

/* 載入檢視 */

  • (UIView *)loadView{ NSLog(@"2"); return _testView; }

相關文章