繁体   English   中英

是我还是Visual Studio 2010?

[英]Is it me or Visual Studio 2010?

每当我为网站编写大型JavaScript库时,我都会使用以下模式。

尽管在运行时一切似乎都很好,但在Visual Studio中却总是有噩梦。

在匿名函数表达式的最后一行,我总是得到错误

“预期的;”

关于最后的结束括号

}(窗口,jQuery));

我已经通过jslint运行了代码,没有任何问题,但是我的智识总是会中断,而且我无法格式化代码。 我错过了什么吗?

; (function (window, $) {

    // Define a local copy of MyLibrary
    var MyLibrary = {},

    // Shortcuts.
    // A central reference to the root messages object
    $$messages,

    // A central reference to the root messages.messageType object
    $$messageType;

    MyLibrary = function () {
        // The MyLibrary object is actually just the init 
        // constructor 'enhanced'
        return new MyLibrary.fn.init();
    };

    MyLibrary.fn = MyLibrary.prototype = {
        init: function () {
            // Initialise the object shortcuts.
            $$messages = MyLibrary.fn.messages;
            $$messageType = MyLibrary.fn.messages.messageType;
        }
    };

    // Give the init function the MyLibrary prototype for later instantiation
    MyLibrary.fn.init.prototype = MyLibrary.fn;

    MyLibrary.fn.messages = {
        /// <summary>
        /// Provides means to provide feedback message to the client.
        /// </summary>
        messageType: {
            information: "information",
            error: "error",
            success: "success"
        }
    };

    MyLibrary.fn.tester = function () {
        alert($$messageType.success);
    };

    // Expose MyLibrary to the global object
    window.MyLibrary = window.$m = MyLibrary();

} (window, jQuery));

jQuery(document).ready(function () {
    $m.tester();
});

; 可能会导致错误。 我不知道为什么是一开始。

} (window, jQuery));

应该

})(window, jQuery);

暂无
暂无

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

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