在IOS项目中使用Weex SDK的时候,从原生界面跳转到Weex容器页面,然后点击Weex容器页面的button跳转到另一个原生界面,JS方法点击无效,同时控制台出现了resource request handler found和没有定义actionBridge 的报错。
解决:添加如下两句代码,注册自定义的JS回调原生方法的事件方法
[WXSDKEngine registerHandler:[WXLJCustomeEventModule new] withProtocol:@protocol(WXModuleProtocol)];
[WXSDKEngine registerModule:@"actionBridge" withClass:[WXLJCustomeEventModule class]];
附注Weex 容器初始化代码
- (void)initWeexSDK
{
[WXAppConfiguration setAppGroup:@"AliApp"];
[WXAppConfiguration setAppName:@"WeexDemo"];
[WXAppConfiguration setExternalUserAgent:@"ExternalUA"];
[WXSDKEngine initSDKEnvironment];
[WXSDKEngine registerHandler:[WXImgLoaderDefaultImpl new] withProtocol:@protocol(WXImgLoaderProtocol)];
[WXSDKEngine registerHandler:[WXNavigationHandlerImpl new] withProtocol:@protocol(WXNavigationProtocol)];
// 注册自定义的JS回调原生方法的事件方法
[WXSDKEngine registerHandler:[WXLJCustomeEventModule new] withProtocol:@protocol(WXModuleProtocol)];
[WXSDKEngine registerModule:@"actionBridge" withClass:[WXLJCustomeEventModule class]];
// 注册自定义的JS回调原生方法的事件方法
#ifdef DEBUG
[WXAnalyzerCenter addWxAnalyzer:[DebugAnalyzer new]];
#endif
#if !(TARGET_IPHONE_SIMULATOR)
[self checkUpdate];
#endif
#ifdef DEBUG
[self atAddPlugin];
[WXDebugTool setDebug:YES];
[WXLog setLogLevel:WXLogLevelLog];
#ifndef UITEST
[[ATManager shareInstance] show];
#endif
#else
[WXDebugTool setDebug:NO];
[WXLog setLogLevel:WXLogLevelError];
#endif
}