npm install --save vue-scrollto //or
yarn add vue-scrollto
//As a vue directive (main.js)
var Vue = require('vue');
var VueScrollTo = require('vue-scrollto');
Vue.use(VueScrollTo)
// You can also pass in the default options
Vue.use(VueScrollTo, {
container: "body",
duration: 500,
easing: "ease",
offset: 0,
cancelable: true,
onStart: false,
onDone: false,
onCancel: false,
x: false,
y: true
})
<!--Usage HTML-->
<a href="#" v-scroll-to="'#element'">Scroll to #element</a>
<div id="element">
Hi. I'm #element.
</div>
<!--If you need to customize the scrolling options, you can pass in an object literal to the directive:-->
<a href="#" v-scroll-to="{
el: '#element',
container: '#container',
duration: 500,
easing: 'linear',
offset: -200,
cancelable: true
onStart: onStart,
onDone: onDone,
onCancel: onCancel,
x: false,
y: true
}">
Scroll to #element
</a>