我在 IE 中加载 JS 时遇到问题。我的文档只有在按 ctrl+r 时才会运行。只有在使用 requirejs 优化器和 IE 时才会出现这种情况。如果我不运行优化器,我会在其他浏览器和 IE 中工作。
require(["jquery", "modals", "registermodule", "bootstrap", "personsmodule"], function($) {
//This is for placeholders in browsers that don't support it.
function createPlaceHoldersForIE(){
    if (typeof document.createElement("input").placeholder == 'undefined') {
        $('[placeholder]').focus(function() {
            var input = $(this);
            if (input.val() == input.attr('placeholder')) {
                input.val('');
                input.removeClass('placeholder');
            }
        }).blur(
                function() {
                    var input = $(this);
                    if (input.val() === '' || input.val() === input.attr('placeholder')) {
                        input.addClass('placeholder');
                        input.val(input.attr('placeholder'));
                    }
                }).blur().parents('form').submit(function() {
            $(this).find('[placeholder]').each(function() {
                var input = $(this);
                if (input.val() == input.attr('placeholder')) {
                    input.val('');
                }
            });
        });
    }
}
// This will allow $(selector).val().trim(); syntax
String.prototype.trim = function() {
    return $.trim(this);
};
$(document).ready(function() {
    createPlaceHoldersForIE();
});
});