简体   繁体   English

未捕获的SyntaxError:意外的令牌if

[英]Uncaught SyntaxError: Unexpected token if

I am getting the error specified in the question title for the following code snippet : 我收到以下代码段的问题标题中指定的错误:

$LAB.queue(function init() {
    FB.init({
        appId: '00000000',
        status: true,
        cookie: true,
        xfbml: true,
        logging: '0'
    });
}
if(window.FB) {
    init();
} else {
    window.fbAsyncInit = init
});

Any ideas as to what might be causing the error? 有关可能导致错误的原因的任何想法? I just cannot figure out the issue. 我只是想不通问题。

If you need to call init anywhere in your script, define it separately and suppy it to your queue() call. 如果需要在脚本中的任何位置调用init,请单独定义它并将其提供给queue()调用。 Also please change your question to indicate your requirement rather than just saying you need help fixing syntax error... 另外,请更改您的问题以表明您的要求,而不仅仅是说您需要帮助修复语法错误...

var init = function() {
    FB.init({
        appId: '00000000',
        status: true,
        cookie: true,
        xfbml: true,
        logging: '0'
    });
};

$LAB.queue(init);

if(window.FB) {
    init();
} else {
    window.fbAsyncInit = init
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM