【问题标题】:Waypoints.js waypoint is not a functionWaypoints.js 航点不是函数
【发布时间】:2020-06-16 22:47:02
【问题描述】:

我收到控制台错误:

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

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

我已经包含了这样的文件(只有这两个 .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>

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

【问题讨论】:

    标签: jquery jquery-waypoints


    【解决方案1】:

    您添加了 独立 库( — 注意 noframework 部分),而不是 jQuery 插件 ()。查看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'/>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-23
      • 2021-09-20
      • 2020-07-24
      • 2021-02-28
      • 1970-01-01
      相关资源
      最近更新 更多