更改字符串会使整个脚本无法在 Titanium 中运行

发布于 2024-11-25 05:59:31 字数 765 浏览 1 评论 0原文

所以我有一个脚本可以创建一个简单的表视图,但是更改一个简单的字符串似乎会产生严重的后果。

这是有效的(我已将其剥离到相关部分):

data = [];
db = Ti.Database.install('../data.sqlite', 'person');
rows = db.execute('SELECT * FROM person');
while (rows.isValidRow()) {
  data.push({
    title: rows.fieldByName('first_name'),
    hasChild: true,
    c_id: rows.fieldByName('C_ID')
  });
  rows.next();
}
tableview = Titanium.UI.createTableView({
  data: data
});
...
win.add(tableview);
...

但是将 title: rows.fieldByName('first_name'), 更改为 title: rows.fieldByName('first_name') + rows。 fieldByName('last_name'), 抛出错误 表达式 'win.add' [] 的结果不是函数。在persons.js(第32行)(第32行是win.add(tableview)

唯一的区别是该行,但它使整个脚本失败。

提前致谢
弗雷德

So I have a script which creates a simple table view, but changing a simple string seems to have drastic consequences.

This works (I have stripped it to the relevant parts):

data = [];
db = Ti.Database.install('../data.sqlite', 'person');
rows = db.execute('SELECT * FROM person');
while (rows.isValidRow()) {
  data.push({
    title: rows.fieldByName('first_name'),
    hasChild: true,
    c_id: rows.fieldByName('C_ID')
  });
  rows.next();
}
tableview = Titanium.UI.createTableView({
  data: data
});
...
win.add(tableview);
...

But changing title: rows.fieldByName('first_name'), to title: rows.fieldByName('first_name') + rows.fieldByName('last_name'), throws an error of
Result of expression 'win.add' [] is not a function. at persons.js (line 32) (line 32 is win.add(tableview).

The only difference is that line but it makes the whole script fail.

Thanks in advance
Fred

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

_畞蕅 2024-12-02 05:59:31

您是否尝试过在它们之间添加空格?

title: rows.fieldByName('first_name') + ' ' + rows.fieldByName('first_name')

如果您从表中取出另一个表?像last_name之类的,它也会崩溃吗?

Have you tried to put a blank space between them?

title: rows.fieldByName('first_name') + ' ' + rows.fieldByName('first_name')

and if you take another table from the table? like last_name or so, does it crash then too?

浅听莫相离 2024-12-02 05:59:31

我发现了问题,这是因为我使用的 CoffeeScript 将代码包装在函数包装器中,这会导致问题(以某种方式)。删除函数包装器修复了它,但现在我不能再使用咖啡脚本了。

I found the problem, it was because I'm using coffeescript which wraps the code in a function wrapper, which causes problems (somehow). Removing the function wrapper fixed it but now I can't use coffeescript any more.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文