Waypoints.js Waypoint不是函数 [英] Waypoints.js waypoint is not a function

查看:330
本文介绍了Waypoints.js Waypoint不是函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到控制台错误:

未捕获的TypeError:$(...).waypoint不是函数

Uncaught TypeError: $(...).waypoint is not a function

仅供参考:这是一个使用XML的Blogger模板.

FYI: It is a Blogger template, which uses XML.

我已经包含了这样的文件(仅这两个.js文件):

I have included the files like so (only these two .js files):

<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js'/>
<script src='https://cdnjs.cloudflare.com/ajax/libs/waypoints/4.0.1/noframework.waypoints.min.js'/>

我的jQuery(为清晰起见,删除了更长的脚本):

My jQuery (longer scripts removed for clarity):

<script>
  // <![CDATA[
    $.noConflict();
    jQuery( document ).ready(function( $ ) {
      <!-- LET'S ADD SPAN ELEMENT TO WIDGET HEADINGS SO WE CAN DO ACCESSIBILITY & INCLUSIVE DESIGN -->
      $('.widget > .title').each(function() { $(this).wrapInner('<span />'); });
      <!-- LET'S ADD A CLASS TO THE MAIN MENU WHEN SCROLLING DOWN PAST THE MAIN HEADER -->
      $("#main-header").waypoint(function() { $('#main-menu').addClass('hide'); }, { offset: '100%' });
      <!-- LET'S MAKE THE PAGE LOADER GO AWAY WHEN PAGE IS LOADED  -->
      $('#page-loading-cover').delay(1500).addClass('page-loaded');
    });
  // ]]>
</script>

为什么它不起作用,我该如何解决?

Why is it not working, and how do I fix it?

推荐答案

您添加了独立库(-注意noframework部分),而不是jQuery插件().请参见此CDN列表,然后选择https://cdnjs.cloudflare.com/ajax/libs/waypoints/4.0.1/jquery.waypoints.min.js,即包含

You added the stand-alone library (waypoint — notice the noframework part), not the jQuery plugin (jquery-waypoints). See this CDN list and pick https://cdnjs.cloudflare.com/ajax/libs/waypoints/4.0.1/jquery.waypoints.min.js, i.e. include

<script src='https://cdnjs.cloudflare.com/ajax/libs/waypoints/4.0.1/jquery.waypoints.min.js'/>

代替

<script src='https://cdnjs.cloudflare.com/ajax/libs/waypoints/4.0.1/noframework.waypoints.min.js'/>

这篇关于Waypoints.js Waypoint不是函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆