Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/370.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在Titanium studio(index.js)中包含.js文件?_Javascript_Macos_Titanium Mobile_Titanium Alloy - Fatal编程技术网

Javascript 如何在Titanium studio(index.js)中包含.js文件?

Javascript 如何在Titanium studio(index.js)中包含.js文件?,javascript,macos,titanium-mobile,titanium-alloy,Javascript,Macos,Titanium Mobile,Titanium Alloy,我不想创建一个包含帮助函数的.js文件。这些函数应该在 index.js 我得到以下错误: [ERROR] : Script Error Couldn't find module: ./helper/WBMHelperFunctions.js for architecture: arm64 下面是代码:(index.js) (wbmhelperfuncations.js) 函数createTabBarControllerWithNumberOfTabs(tabsNumber,tabNames

我不想创建一个包含帮助函数的.js文件。这些函数应该在

index.js

我得到以下错误:

[ERROR] :  Script Error Couldn't find module: ./helper/WBMHelperFunctions.js for architecture: arm64
下面是代码:(index.js)

(wbmhelperfuncations.js)

函数createTabBarControllerWithNumberOfTabs(tabsNumber,tabNamesArray)
{
var tabBarController=tianium.UI.createTabGroup();
对于(i=0;i
这是两个月前提出的问题,希望您现在已经有了答案,但是对于任何看到此页面的人:

假设文件位于指定的路径中,则

var helperFunctionsModule = require('./helper/WBMHelperFunctions.js');
是不正确的,因为“.js”

应该是:

var helperFunctionsModule = require('./helper/WBMHelperFunctions');

您可以将助手文件放在应用程序的lib文件夹中

若您正在使用Alloy for titanium项目,则可以在项目中“应用程序文件夹”下的lib文件夹中创建require helper文件

要访问或包含项目中的任何文件,可以使用以下代码。在本例中,我们使用testHelper.js文件包含在index.js文件中

var helper = requier("testHelper");
注意:在包含放置在lib文件夹中的文件时,不要使用.js扩展名

var helperFunctionsModule = require('./helper/WBMHelperFunctions');
var helper = requier("testHelper");