Vue use custom JavaScript plugin
-
Hi!
I have a custom JavaScript plugin I need to use inside the “created” hook of some components. It’s a slideshow plugin that returns an object so i can callvar slidesnow = new SlideShow(target)
How can I achieve that? I’m a Vue noobie.This is the plugin I need to use: https://jsfiddle.net/k5nvyqkp/1/
-
This post is deleted! -
How about just using the slider component?
Also, this is how to add a plug-in to vue. https://vuejs.org/v2/guide/plugins.html#Writing-a-Plugin
Scott
-
@s.molinari I need to use this exact plugin for the sake of design & UX.
-
Use a Vue reference on the target node in the template. On the mounted() hook, inside a this.$nextTick() use that Vue reference (new SlideShow(this.$refs.<target-ref-name>).
-
I have managed to access the constructor in the hook using
window.SlideShow
and the script is required using regular<script>
tags in the index.html file.