我得到了以下lua.vm.js代码:
local data=tostring(js.global.Module.read('/statsWidget.lcgi'))
print(data)
print(js.global.document.getElementById('statsWidget').innerHTML)
js.global.document.getElementById('statsWidget').innerHTML=data
虽然ajax调用和两个打印工作正常,但尝试设置innerHTML会引发javascript错误:
Uncaught SyntaxError: Unexpected identifier lua.vm.js:5717
_emscripten_run_script_int lua.vm.js:5717
iS lua.vm.js:6406
eX lua.vm.js:6406
iM lua.vm.js:6406
eZ lua.vm.js:6406
iD lua.vm.js:6406
iM lua.vm.js:6406
eZ lua.vm.js:6406
dB lua.vm.js:6406
k1 lua.vm.js:6407
invoke_vii lua.vm.js:6359
eS lua.vm.js:6406
e2 lua.vm.js:6406
dA lua.vm.js:6406
cD lua.vm.js:6406
ccallFunc lua.vm.js:536
ccall lua.vm.js:495
Lua.execute lua.vm.js:6608
(anonymous function) lua.vm.js:6614
Lua.executeScripts lua.vm.js:6613
window.onload lua.vm.js:6603
我做错了什么?
答案 0 :(得分:1)
我无法验证您的数据,但对我而言,这有效:
-- working
js.global.document:getElementById('statsWidget').innerHTML= "foo"
虽然失败了:
-- not working
js.global.document.getElementById('statsWidget').innerHTML= "foo"
注意文档后面的冒号。它为函数添加了一个隐藏的自身参数:
-- working too
js.global.document.getElementById(js.global.document,'statsWidget').innerHTML= "foo"