Answer the question
In order to leave comments, you need to log in
How to connect global jquery plugin on vue.js?
Hello.
How to correctly connect the OnePageScroll plugin ( www.thepetedesign.com/demos/onepage_scroll_demo.html ) to vue.js?
I have an example of how to connect such plugins to vue.js via npm, but I don’t know how to connect just a plugin, not via npm.
You need it right, and not just add .css and .js to index.html
Answer the question
In order to leave comments, you need to log in
If not via NPM, then via CDN. Open your index.html and add links.
But most likely you are interested in how to make it work. There are two options:
1. Through a hook:
export default {
// mounted неплохой вариант, если document должен быть ready
mounted () {
const $ = window.$
$('.main').onepage_scroll()
}
}
export default {
directives: {
// Произвольное имя директивы
onePageScroll: {
// На этом хуке компонент со всеми дочерними компонентами готов
componentUpdated (el) {
const $ = window.$
// Елемент не нужно «селектить» по классу/ИД т.к. он передан в аргументы директивы
$(el).onepage_scroll()
}
}
}
}
<div>
<section v-one-page-scroll />
</div>
If using webpack then use providePlugin to include jquery.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question