waypoint Uncaught TypeError: Cannot read property 'each' of undefined

橙三吉。 提交于 2019-12-11 17:54:22

问题


I am using waypoint and it send me this message:

Uncaught TypeError: Cannot read property 'each' of undefined

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.


回答1:


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

Can a DOM element have an ID that contains a space?



来源:https://stackoverflow.com/questions/46105786/waypoint-uncaught-typeerror-cannot-read-property-each-of-undefined

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!