1

我正在使用 Appcelerator 开发一个移动应用程序,并包含一些使用 commonJS 的配置功能。

我正在运行的代码如下:

应用程序.js

var well = {};

well.config = require('config');

配置.js

var configJson = JSON.parse(Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory,'config.json'));
exports.getFeed = function(_feed){
    return configJson.feeds.sermon[_feed];
};

当我尝试运行代码时,出现以下错误:

Location:
[3,0] file:///android_asset/Resources/app.js
Wrapped java.lang.IllegalArgumentException: size must be >= 0 (file:///android_asset/Resources/app.js#3)

我做错了什么来包含模块吗?

4

1 回答 1

1

您需要关闭 fastdev 并且它会正常工作,将其添加到您的 tiapp.xml

<property name="ti.android.fastdev" type="bool">false</property>
<property name="ti.android.compilejs" type="bool">true</property>

我正在使用 1.7.2,它在 android 上运行良好

于 2011-10-07T01:11:49.730 回答