[INFO] iPhone 设备系列:iphone [INFO] iPhone SDK 版本:5.0 [INFO] Projekt/1.0 (2.0.2.GA.2ff31a3)
我正在 Appcelerator 中构建一个 iOS 应用程序,在这个应用程序中,我想为我添加到全局变量中的 UI 组件创建一个 CommonJS 模块,然后在其他 commonJS 模块中使用它。
我的代码基于这个例子:
http://developer.appcelerator.com/blog/2011/09/forging-titanium-episode-6-a-single-context-tabbed-application-template.html
我将它添加到 app.js 中,如下所示:
var globals = {};
globals.Components = require ('ui/Components');
我在其他模块中使用它,如下所示:
var button_right = new globals.Components.NavBarButton ();
这是一个好方法吗?