我使用 Rhino 时遇到 SyntaxError: Missing } after property list
,但以下脚本无法编译:
importClass(org.scripthelper.js.samples.ScriptTag)
script11Class = new JavaAdapter(org.scripthelper.js.samples.ScriptTag, {
init: function(ctx) {
context = ctx;
}
function externalPressed() {
return 1;
}
});
错误出现在 externalPressed
函数声明行。
但是如果我通过以下方式更改代码:
importClass(org.scripthelper.js.samples.ScriptTag)
script11Class = new JavaAdapter(org.scripthelper.js.samples.ScriptTag, {
init: function(ctx) {
context = ctx;
},
externalPressed: function() {
return 1;
}
});
它工作正常。
我做错了什么?我确信第一种情况不是有效的 Javascript,但我不明白为什么
最佳答案
因为没有有效的构造函数。另外,编译器将在以下几行中解释什么。
{
init: function(ctx) {
context = ctx;
}
function externalPressed() {
return 1;
}
显然,它显示了两个 block 。
关于javascript - 使用 Rhino 的 javascript 出现语法错误 : SyntaxError: missing } after property list,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61689003/