[英]Syntax error in javascript usign Rhino: SyntaxError: missing } after property list
I have a SyntaxError: missing } after property list
using Rhino with the following script which does not compile:我有一个
SyntaxError: missing } after property list
using Rhino with the following script which doesn'tcompile:
importClass(org.scripthelper.js.samples.ScriptTag)
script11Class = new JavaAdapter(org.scripthelper.js.samples.ScriptTag, {
init: function(ctx) {
context = ctx;
}
function externalPressed() {
return 1;
}
});
The error is on the externalPressed
function declaration line.错误出现在
externalPressed
function 声明行上。
But if I change my code by:但是,如果我通过以下方式更改我的代码:
importClass(org.scripthelper.js.samples.ScriptTag)
script11Class = new JavaAdapter(org.scripthelper.js.samples.ScriptTag, {
init: function(ctx) {
context = ctx;
},
externalPressed: function() {
return 1;
}
});
It works correctly.它工作正常。
What did I do wrong?我做错了什么? I'm sure that the first case is not valid Javascript, but I dont see why
我确定第一种情况是无效的 Javascript,但我不明白为什么
Because There's not a valid constructor.因为没有有效的构造函数。 Also, what the compiler will interpret in the following lines.
此外,编译器将在以下几行中解释什么。
{
init: function(ctx) {
context = ctx;
}
function externalPressed() {
return 1;
}
Clearly, It shows two blocks.显然,它显示了两个块。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.