航路点未捕获的TypeError:无法读取未定义的属性"each" [英] waypoint Uncaught TypeError: Cannot read property 'each' of undefined

查看:132
本文介绍了航路点未捕获的TypeError:无法读取未定义的属性"each"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用航点,它会向我发送此消息:

I am using waypoint and it send me this message:

未捕获的TypeError:无法读取未定义的属性"each"

这是我通过vue.js + rails获得代码的方式:

this is how I got the code with vue.js + rails:

<template>
      <div id="playerContainer final">
         <iframe src="xxxxxxxxx" allowfullscreen></iframe> 
       </div>
</template>

<script>
  require('waypoints/lib/jquery.waypoints.min.js')
  export default {
    mounted(){
      var ele
      new Waypoint({
        element: ele = document.getElementById('final'),
        handler: function(direction) {
          if (direction == 'down') {
            $(ele).addClass('muestra')
          } else {
            $(ele).removeClass('muestra')
          }
          console.log(direction);
        }
      });
    }
  }
<script>

如果您能帮助我解决这个问题,我将非常感谢.

I will really appreciate guys if you ca help me with this issue.

推荐答案

我发现div不能包含多个ID.如果在getElementById中指定整个ID,则可以正常工作.

I found that div cannot contain multiple ids. You can get it work if you specify whole id in getElementById.

ele = document.getElementById('playerContainer final')

> DOM元素可以有一个ID吗?包含空格?

这篇关于航路点未捕获的TypeError:无法读取未定义的属性"each"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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