question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Vue warn]: Failed to resolve directive: waypoint

See original GitHub issue

Hi there,

I’m fairly new to vue.js and am just trying to see if I can use this for a project that requires some animation on scroll. The vue.js CLI was used to scaffold the project. I simply included the sample code you have in your readme, but keep getting a [Vue warn]: Failed to resolve directive: waypoint in the console. Here’s my component:

<template>
  <div class="hello">
    <h1>{{ msg }}</h1>
    <div v-waypoint="{ active: true, callback: onWaypoint, options: intersectionOptions }"></div>
  </div>
</template>

<script>
import Vue from 'vue'
import VueWaypoint from 'vue-waypoint'

// Waypoint plugin
Vue.use(VueWaypoint)

export default {
  name: 'HelloWorld',
  data () {
    return {
      msg: 'Welcome to Your Vue.js App',
      intersectionOptions: {
        root: null,
        rootMargin: '0px 0px 0px 0px',
        thresholds: [0]
      } // https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API
    }
  },
  methods: {
    onWaypoint ({ going, direction }) {
      // going: in, out
      // direction: top, right, bottom, left
      if (going === this.$waypointMap.GOING_IN) {
        console.log('waypoint going in!')
      }

      if (direction === this.$waypointMap.DIRECTION_TOP) {
        console.log('waypoint going top!')
      }
    }
  }
}
</script>

I may just be using Vue.use() incorrectly? Please let me know if you have any tips!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
scaccogattocommented, Dec 17, 2017

@colloquet reply just found the problem. The library is not correctly exported as library by the webpack configuration.

I just pushed the related hotfix (b591d0cfd7204b7536d17772eac5e21f510396c8). Please run and update and change your code from:

import VueWaypoint from 'vue-waypoint'/src

to

import VueWaypoint from 'vue-waypoint'

This will work and it’s tested.

Beside that @juliewongbandue, I would suggest you not to use document.querySelector or any DOM reference inside Vue’s lifecycle methods: they are not always reliable. You can find a cleaner way by using directives.

Thanks for this, I will keep this open for two days if something is missing.

0reactions
colloquetcommented, Dec 18, 2017

@scaccogatto I see, thanks again for your work on this library.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Vue warn]: Failed to resolve directive: bin - Stack Overflow
I've had this issue in the form of Failed to resolve directive: disabled which sounded cryptic, but was actually me thinking Vue is...
Read more >
[Vue warn]: Failed to resolve directive: mode - Laracasts
I have been using Vue 2 for a couple of weeks now and recently I started to receive the following error: [Vue warn]:...
Read more >
Custom directive: [Vue warn]: Failed to resolve directive
I use vue3 with nuxt3 and have a custom directive. /plugins/animateOnScroll.client.js ` const options = { root: null, rootMargin: '50px',
Read more >
[Vue Warn]: Failed To Resolve Directive - ADocLib
I have been using Vue 2 for a couple of weeks now and recently I started to receive the following error: [Vue warn]:...
Read more >
A curated list of awesome things related to Vue.js
Content and all rights reserved to github.com/vuejs/awesome-vue Awesome Vue.js A... Tagged with vue.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found