是我的问题还是Visual Studio 2010的问题

Is it me or Visual Studio 2010?

本文关键字:问题 2010 Studio 我的 Visual      更新时间:2023-09-26

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

虽然在运行时一切看起来都很好,但在visual studio中总是有一个噩梦。

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

"预期;"

最后一个右括号 上的

} (window, 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);