DOM模块默认未在 WxSDKEngine注册

  1. try {
  2. if (WXDomModule.WXDOM.equals(module)) {//dom 模块默认未在WxSDKEngine注册...why?
  3. WXDomModule dom = WXModuleManager.getDomModule(instanceId);
  4. if(dom != null){
  5. return dom.callDomMethod(method, arguments);
  6. } else {//dom 模块没注册成功时,在此重新创建
  7. createDomModule(WXSDKManager.getInstance().getSDKInstance(instanceId));
  8. }
  9. } else {//非dom模块
  10. return callModuleMethod(instanceId, module,
  11. method, arguments, options);
  12. }

�DOM对应方法的使用明细

/** package **/
  /**
   * Dom注册的key {@link WXBridgeManager#registerDomModule()}
   * 告诉js框架需要注入什么dom方法,添加时需要在{@link #METHODS}
   * 中加入方法名字,具体的在{@link #callDomMethod(String, JSONArray, long...)}
   * 中实现
   */
  public static final String WXDOM = "dom";

  /**
   * 移动到某个元素
   * weex.requireModule('dom').scrollToElement(this.$refs.header)
   */
public static final String SCROLL_TO_ELEMENT = "scrollToElement";
  /**
   * 添加字体的支持
   * var dom = weex.requireModule('dom');
   * //目前支持ttf、woff文件,不支持svg、eot类型
   * dom.addRule('fontFace', {
   *   'fontFamily': "iconfont2",
   *   'src': "url('http://at.alicdn.com/t/font_1469606063_76593.ttf')"
   * });
   */
public static final String ADD_RULE = "addRule";
  /**
   * 获取组件的rect坐标
   * 例如 ref=block 元素坐标获取
   * dom.getComponentRect(this.$refs.block, option => {
   *               console.log('getComponentRect:', option)
   *               this.top = option.size.top;
   *               this.left = option.size.left;
   *             })
   */
public static final String GET_COMPONENT_RECT = "getComponentRect";

  /**
   * JS中调用native的方法 - 通常是反射调用某个组件的方法
   * java入口 {@link WXBridgeManager#callNativeComponent(String, String, String, JSONArray, Object)}
   *       WXDomModule dom = WXModuleManager.getDomModule(instanceId);
   *       dom.invokeMethod(componentRef, method, arguments);
   * 目前好像还没明确使用
   */
public static final String INVOKE_METHOD = "invokeMethod";

  /**
   * 全部更新组件相关的信息,应该需要全局刷新,目前没看到哪里有使用
   * 好像只对 {@link com.taobao.weex.ui.component.list.template.WXRecyclerTemplateList} 生效
   * 见{@link UpdateComponentDataAction#executeAction()}
   */
public static final String UPDATE_COMPONENT_DATA = "updateComponentData";

//目前没看到任何相关的使用场景和用例
public static final String BATCH_BEGIN = "beginBatchMark";
public static final String BATCH_END = "endBatchMark";