Waypoints.js 航路点不是函数

Waypoints.js waypoint is not a function

我收到控制台错误:

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

仅供参考:这是一个 Blogger 模板,使用 XML。

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

<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(为清楚起见删除了较长的脚本):

<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>

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

您添加了 独立 库( — notice the noframework part), not the jQuery plugin (). See this CDN list 并选择 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/jquery.waypoints.min.js'/>

而不是

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