2017-09-06 1 views
0

vue.js를 사용 중이고 waypoints을 포함하고 싶습니다.vue.js에서 웨이 포인트를 사용할 때의 문제

내 원래, 작업, 스크립트

HTML :

<div id="final"> 
    <h2>Mostar el mensaje al pasar por aqui</h2> 
</div> 

스크립트

var ele 
var waypoint = new Waypoint({ 
    element: ele = document.getElementById('final'), 
    handler: function(direction) { 
    if (direction == 'down') { 
     $(ele).addClass('muestra') 
    } else { 
     $(ele).removeClass('muestra') 
    } 
    console.log(direction); 
    } 
}); 

CSS :이 코드를 사용하려고 해요

.muestra { 
    position: fixed; 
    bottom: 20px; 
    right: 20px; 
} 

vue.js에 있지만, 그것은 나에게 준다.

Uncaught ReferenceError: Waypoint is not defined

이 vue.js의 코드는 다음과 같습니다 : 콘솔에 메시지입니다

galeri.vue :

<template> 
    <div id="final"> 
    <h2>Mostar el mensaje al pasar por aqui</h2> 
    </div> 
</template> 
<script> 
    var ele 
    var waypoint = new Waypoint({ 
    element: ele = document.getElementById('final'), 
    handler: function(direction) { 
     if (direction == 'down') { 
     $(ele).addClass('muestra') 
     } else { 
     $(ele).removeClass('muestra') 
     } 
     console.log(direction); 
    } 
    }); 
</script> 

내가 잘못하고있는 중이 야 어떤 생각? 당신이 npm install waypoints를 통해 중간 지점을 설치 한 이후

+0

당신이 내가 사용 웨이 포인트를 프로젝트에 웨이 포인트를 가져 오기 파일 – thanksd

+0

에 웨이 포인트를 가져와야 - npm은 중간 지점 설치 –

답변

1

그렇게처럼 파일을 require해야합니다

<script> 
require('waypoints/lib/noframework.waypoints.js') 

var waypoint = new Waypoint({ 
    // ... 
}) 
</script> 

Found on the waypoints Github.