尝试调用字段'defaultName'(一个字符串值),出现错误。

当我在下面的代码中添加 " some more text " 时,我收到一个奇怪的**Attempt to call field 'defaultName' (a string value)**类型的错误:

--
alert = native.showAlert( "saved!",  "Your score is saved to " ..defaultName " some more text " ..allScore_txt , { "Done" }, onComplete )
--

有任何建议如何修复这个问题吗?

点赞
用户107090
用户107090

你在 defaultName 后面缺少了 ..,因此 Lua 认为你是想要调用一个函数,所以就会出现错误提示。Lua 允许以 identifier"string" 的形式进行函数调用,这是 identifier("string") 的简写形式。

2013-09-27 19:35:32