I'm trying to use NPM package scroll-ease-efficient in my Nuxt/Vue app, so I've created a file called scroll-ease-efficient.client.js in plugins/ folder that I specified in the plugins section of my nuxt.config.js file.
Here is the content of the file:
import Vue from 'vue'
import { scrollTo } from 'scroll-ease-efficient'
Vue.use(scrollTo)
Then in my app I simply do:
const scrollEle = document.getElementById('element')
scrollTo(scrollEle, 500)
This should work but it does nothing, and I have no console error either.
What's wrong?
Vue.use()have to subscribe to a specific interface: it should have aninstallmethod that takes two arguments: vuejs.org/v2/guide/plugins.html#Writing-a-Plugin. Objects that do not meet this requirement cannot be used as a plugin.scrollTo(undefined)just does nothing: github.com/TheoXiong/scroll-ease-efficient/blob/…scrollEleis correctly defined