在Weex中定制自定义组件

1.配置自定义组件

public class  MyViewComponent extends WXComponent{

       public MyViewComponent(WXSDKInstance instance, WXDomObject node, 
                    WXVContainer parent,  String instanceId, boolean lazy) {                
           super(instance, node, parent, instanceId, lazy);
        }

       @Override
       protected void initView() {
          //TODO:your own code ……
       }

      @Override
      public WXFrameLayout getView() {
         //TODO:your own code ………        
      }
      @WXComponentProp(name=WXDomPropConstant.WX_ATTR_VALUE)
      public void setMyViewValue(String value) {
         ((TextView)mHost).setText(value);
      }

}

2.注册组件

WXSDKEngine.registerComponent("MyView", MyViewComponent.class);

 

posted @ 2016-07-03 17:14  JsonLu  阅读(1952)  评论(0编辑  收藏  举报