ReferenceError:在main.js文件中未定义jQuery

时间:2017-04-14 14:43:48

标签: javascript jquery

我突然遇到这个错误。我没有使用Javascript或jQuery代码,所以不确定为什么我突然得到这个错误。

这是我在尝试运行代码时遇到的错误:

 Debugger listening on [::]:15454
 /home/ubuntu/workspace/assets/js/main.js:232
 }(jQuery);
   ^

 ReferenceError: jQuery is not defined

代码:

(function($) {

skel.breakpoints({
    xxlarge: '(max-width: 1920px)',
    xlarge: '(max-width: 1680px)',
    large: '(max-width: 1280px)',
    medium: '(max-width: 1000px)',
    small: '(max-width: 736px)',
    xsmall: '(max-width: 480px)',
});

$(function() {

    var $window = $(window),
        $body = $('body'),
        $header = $('#header'),
        $all = $body.add($header);

    // Disable animations/transitions until the page has loaded.
        $body.addClass('is-loading');

        $window.on('load', function() {
            window.setTimeout(function() {
                $body.removeClass('is-loading');
            }, 0);
        });

    // Touch mode.
        skel.on('change', function() {

            if (skel.vars.mobile || skel.breakpoint('small').active)
                $body.addClass('is-touch');
            else
                $body.removeClass('is-touch');

        });

    // Fix: Placeholder polyfill.
        $('form').placeholder();

    // Fix: IE flexbox fix.
        if (skel.vars.IEVersion <= 11
        &&  skel.vars.IEVersion >= 10) {

            var $main = $('.main.fullscreen'),
                IEResizeTimeout;

            $window
                .on('resize.ie-flexbox-fix', function() {

                    clearTimeout(IEResizeTimeout);

                    IEResizeTimeout = setTimeout(function() {

                        var wh = $window.height();

                        $main.each(function() {

                            var $this = $(this);

                            $this.css('height', '');

                            if ($this.height() <= wh)
                                $this.css('height', (wh - 50) + 'px');

                        });

                    });

                })
                .triggerHandler('resize.ie-flexbox-fix');

        }

    // Prioritize "important" elements on small.
        skel.on('+small -small', function() {
            $.prioritize(
                '.important\\28 small\\29',
                skel.breakpoint('small').active
            );
        });

    // Gallery.
        $window.on('load', function() {

            var $gallery = $('.gallery');

            $gallery.poptrox({
                baseZIndex: 10001,
                useBodyOverflow: false,
                usePopupEasyClose: false,
                overlayColor: '#1f2328',
                overlayOpacity: 0.65,
                usePopupDefaultStyling: false,
                usePopupCaption: true,
                popupLoaderText: '',
                windowMargin: 50,
                usePopupNav: true
            });

            // Hack: Adjust margins when 'small' activates.
                skel
                    .on('-small', function() {
                        $gallery.each(function() {
                            $(this)[0]._poptrox.windowMargin = 50;
                        });
                    })
                    .on('+small', function() {
                        $gallery.each(function() {
                            $(this)[0]._poptrox.windowMargin = 5;
                        });
                    });

        });

    // Section transitions.
        if (skel.canUse('transition')) {

            var on = function() {

                // Galleries.
                    $('.gallery')
                        .scrollex({
                            top:        '30vh',
                            bottom:     '30vh',
                            delay:      50,
                            initialize: function() { $(this).addClass('inactive'); },
                            terminate:  function() { $(this).removeClass('inactive'); },
                            enter:      function() { $(this).removeClass('inactive'); },
                            leave:      function() { $(this).addClass('inactive'); }
                        });

                // Generic sections.
                    $('.main.style1')
                        .scrollex({
                            mode:       'middle',
                            delay:      100,
                            initialize: function() { $(this).addClass('inactive'); },
                            terminate:  function() { $(this).removeClass('inactive'); },
                            enter:      function() { $(this).removeClass('inactive'); },
                            leave:      function() { $(this).addClass('inactive'); }
                        });

                    $('.main.style2')
                        .scrollex({
                            mode:       'middle',
                            delay:      100,
                            initialize: function() { $(this).addClass('inactive'); },
                            terminate:  function() { $(this).removeClass('inactive'); },
                            enter:      function() { $(this).removeClass('inactive'); },
                            leave:      function() { $(this).addClass('inactive'); }
                        });

                // Contact.
                    $('#contact')
                        .scrollex({
                            top:        '50%',
                            delay:      50,
                            initialize: function() { $(this).addClass('inactive'); },
                            terminate:  function() { $(this).removeClass('inactive'); },
                            enter:      function() { $(this).removeClass('inactive'); },
                            leave:      function() { $(this).addClass('inactive'); }
                        });

            };

            var off = function() {

                // Galleries.
                    $('.gallery')
                        .unscrollex();

                // Generic sections.
                    $('.main.style1')
                        .unscrollex();

                    $('.main.style2')
                        .unscrollex();

                // Contact.
                    $('#contact')
                        .unscrollex();

            };

            skel.on('change', function() {

                if (skel.breakpoint('small').active)
                    (off)();
                else
                    (on)();

            });

        }

    // Events.
        var resizeTimeout, resizeScrollTimeout;

        $window
            .resize(function() {

                // Disable animations/transitions.
                    $body.addClass('is-resizing');

                window.clearTimeout(resizeTimeout);

                resizeTimeout = window.setTimeout(function() {

                    // Update scrolly links.
                        $('a[href^="#"]').scrolly({
                            speed: 1500,
                            offset: $header.outerHeight() - 1
                        });

                    // Re-enable animations/transitions.
                        window.setTimeout(function() {
                            $body.removeClass('is-resizing');
                            $window.trigger('scroll');
                        }, 0);

                }, 100);

            })
            .load(function() {
                $window.trigger('resize');
            });

});

})(jQuery);

修改

这是index.html底部的代码

</footer>

<!-- Scripts -->
<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/jquery.poptrox.min.js"></script>
<script src="assets/js/jquery.scrolly.min.js"></script>
<script src="assets/js/jquery.scrollex.min.js"></script>
<script src="assets/js/skel.min.js"></script>
<script src="assets/js/util.js"></script>
<!--[if lte IE 8]><script src="assets/js/ie/respond.min.js"></script><![endif]-->
<script src="assets/js/main.js"></script>

</body>

</html>

这是index.html底部的代码

<!-- Scripts -->
<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/jquery.poptrox.min.js"></script>
<script src="assets/js/jquery.scrolly.min.js"></script>
<script src="assets/js/jquery.scrollex.min.js"></script>
<script src="assets/js/skel.min.js"></script>
<script src="assets/js/util.js"></script>
<!--[if lte IE 8]><script src="assets/js/ie/respond.min.js"></script><![endif]-->
<script src="assets/js/main.js"></script>

0 个答案:

没有答案