Javascript 为什么JSFIDLE会给我这个错误;SyntaxError:意外的标记:“;?
我使用的是结构化javascript代码,它在我的计算机上运行良好。但是,当我将其添加到JSFIDLE时,会出现以下错误:Javascript 为什么JSFIDLE会给我这个错误;SyntaxError:意外的标记:“;?,javascript,jsfiddle,Javascript,Jsfiddle,我使用的是结构化javascript代码,它在我的计算机上运行良好。但是,当我将其添加到JSFIDLE时,会出现以下错误: SyntaxError: Unexpected token : 我的代码如下所示: var StentGallery = { gallery: null, init : function(){ this.gallery = jQuery('#gallery-list-ui'); this.resizeIma
SyntaxError: Unexpected token :
我的代码如下所示:
var StentGallery = {
gallery: null,
init : function(){
this.gallery = jQuery('#gallery-list-ui');
this.resizeImage();
}
}
(...)
}
有人知道为什么这在JSFIDLE中不起作用吗?请看我的小提琴:您的代码中有语法错误:
var StentGallery = {
gallery: null,
init : function(){
this.gallery = jQuery('#gallery-list-ui');
this.resizeImage();
} // <----- this is prematurely closing your object
},
resizeImage: function(){
...
您的init函数还有一个额外的结尾“}”。谢谢!在我把代码从小提琴上拆下来之后,我没有看到这一点。@Steven很高兴我能帮上忙!别忘了那两个丢失的';'在$img.css调用之后。@Mr_Pouet JavaScript将隐式添加这些分号,不过最好是自己始终包含这些分号。
var StentGallery = {
gallery: null,
init : function(){
this.gallery = jQuery('#gallery-list-ui');
this.resizeImage();
},
resizeImage: function(){
...