Regular NPM package not functioning within Vue.js app Regular NPM package not functioning within Vue.js app vue.js vue.js

Regular NPM package not functioning within Vue.js app


thanks for asking. But first, let me clarify. Not all npm package is intended to be installed using Vue/Nuxt plugin method. The regular npm package name for this way often contains word vue/nuxt, like Vuetify or Vuefire.

And scroll-ease-efficient package isn't vue nor nuxt plugin. So in order to use this package, you can add global api from that package to vue or nuxt constructor.

import Vue from "vue";import { scrollTo } from "scroll-ease-efficient";Vue.prototype.$scrollTo = scrollTo;

Now you can access the global method through this.$scrollTo()


Edit

Please checkout this link for the demo: https://codesandbox.io/s/vue-scroll-ease-efficient-demo-8tqmj