本文介绍了航点功能未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始要在要创建的站点中使用Waypoint.

I am just starting out with Waypoints in a site I want to create.

出于测试目的,我创建了一个包含4个彩色div的页面.我想测试当我滚动到第二个div时路标是否触发了功能.

For test purposes, I created a page with 4 colored divs. I want to test if waypoints fires a function when I scroll to the second div.

但是控制台会显示错误:Uncaught ReferenceError: Waypoint is not defined

However the console spits an error: Uncaught ReferenceError: Waypoint is not defined

HTML:

    <!DOCTYPE html>
<html>

  <head>
    <script data-require="jquery@*" data-semver="2.1.4" src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
    <script data-require="[email protected]" data-semver="2.0.4" src="//cdnjs.cloudflare.com/ajax/libs/waypoints/2.0.4/waypoints.min.js"></script>
    <link rel="stylesheet" href="style.css" />
    <script src="script.js"></script>
  </head>

  <body>
    <div id="one"></div>
    <div id="two"></div>
    <div id="three"></div>
    <div id="four"></div>
  </body>

</html>

CSS:

#one{
  background-color:red;
 // width:100%;
  height:400px;
}

#two{
  background-color:blue;
  float:clear;
  height:400px;
}

#three{
  background-color:green;
  height:400px;
}

#four{
  background-color:yellow;
  height:400px;
}

JQUERY/航点:

JQUERY/WAYPOINTS:

var waypoint = new Waypoint({
  element: document.getElementById('#two'),
  handler: function(direction) {
    alert('I am 20px from the top of the window');
  },
});

这是链接到punker.

推荐答案

您需要Waypoints版本2.0.4,但使用方式仅适用于Waypoints 3.0+.升级到最新版本.

You are requiring Waypoints version 2.0.4 but using it in a way that only works with Waypoints 3.0+. Upgrade to the latest version.

这篇关于航点功能未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-23 12:35