gpt4 book ai didi

javascript - 为什么 jsfiddle 给我错误 "SyntaxError: Unexpected token :"?

转载 作者:搜寻专家 更新时间:2023-11-01 05:10:30 24 4
gpt4 key购买 nike

我正在使用结构化的 javascript 代码,它在我的电脑上运行良好。但是当我将它添加到 jsFiddle 时,它​​给了我以下错误:

SyntaxError: Unexpected token :

我的代码是这样的:

var StentGallery = {
gallery: null,

init : function(){
this.gallery = jQuery('#gallery-list-ui');
this.resizeImage();
}
}
(...)
}

有谁知道为什么这在 jsFiddle 中不起作用?
在这里查看我的 fiddle :https://jsfiddle.net/smyhbckx/

最佳答案

您的代码中存在语法错误:

var StentGallery = {
gallery: null,

init : function(){
this.gallery = jQuery('#gallery-list-ui');
this.resizeImage();
} // <----- this is prematurely closing your object
},

resizeImage: function(){
...

要解决这个问题,只需删除那个括号:

var StentGallery = {
gallery: null,

init : function(){
this.gallery = jQuery('#gallery-list-ui');
this.resizeImage();
},

resizeImage: function(){
...

关于javascript - 为什么 jsfiddle 给我错误 "SyntaxError: Unexpected token :"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34120947/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com