vue-scrollto icon indicating copy to clipboard operation
vue-scrollto copied to clipboard

Added example with Vue3 in README

Open logotip4ik opened this issue 4 years ago • 4 comments

This fixes issue #380

  • Added example, how to use vue-scrollto with Vue 3.x
  • Changed a little bit README

logotip4ik avatar Dec 21 '20 20:12 logotip4ik

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 avatar Dec 22 '20 18:12 logotip4ik

@logotip4ik hmm, I'll need to check - I'm not sure actually 🤔

rigor789 avatar Dec 22 '20 19:12 rigor789

The functionality said it was merged, it doesn't seem to work in vue3 no matter what configuration is provided. :(

wparad avatar Sep 25 '23 17:09 wparad

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');

dan-whitehouse avatar Jan 18 '24 18:01 dan-whitehouse