vue-scrollto
vue-scrollto copied to clipboard
Added example with Vue3 in README
This fixes issue #380
- Added example, how to use vue-scrollto with Vue 3.x
- Changed a little bit README
How do you pass or set defaults for vue-scrollto in Vue 3? I tried to use setDefaults function
VueScrollTo.setDefaults({
duration: 2000,
});
but is says: setDefaults is not a function, also tried to do like this:
app.directive('scroll-to', VueScrollTo, { duration: 1000 })
but it hadn't got any effect.
@logotip4ik hmm, I'll need to check - I'm not sure actually 🤔
The functionality said it was merged, it doesn't seem to work in vue3 no matter what configuration is provided. :(
My suggestion would be to use use and directive together. When just using use my IDE (IntelliJ) doesn't recognize the directive (Unrecognized Vue directive). And just using directive, there isn't a way to set the defaults. However, if I combine the two, the IDE is happy and the directive uses the defaults set up in use.
I'm not sure if this is best practice (probably not), but hopefully this helps.
import { createApp } from 'vue';
import VueScrollTo from 'vue-scrollto';
const app = createApp(App);
app.use(VueScrollTo, {
duration: 1000,
easing: "ease"
})
app.directive('scroll-to', VueScrollTo)
app.mount('#app');