2

I am trying to convert an html project into a vue app.
The original project uses jquery plugin for Revolution slider by adding them via script tag inside html file's body tag and later initializing them:

<script type="text/javascript" src="/static/revolution/js/jquery.themepunch.tools.min.js"></script>
<script type="text/javascript" src="/static/revolution/js/jquery.themepunch.revolution.min.js"></script>

What is the best way to add revolution slider to my vue project?

I have installed jquery via npm and tried to import these scripts into the main.js entrypoint file. I am not familiar with node or npm. Also when app loads, the jQuery is undefined inside these scripts raising errors in the console, which means there is something wrong.

philoj
  • 468
  • 2
  • 13

2 Answers2

0

The easiest way is probably to load jquery in the same way (before those two script tags).

Eindbaas
  • 945
  • 1
  • 8
  • 16
  • but I already need jquery somewhere else and have installed it via npm. Adding it via script tag would create a duplicate... – philoj Mar 06 '19 at 15:59
0

Import jQuery into your main.js and then set window.$

import $ from 'jquery'
window.$ = $

That will make it available globally so the scripts can use $ in the standard way.

ezero
  • 1,230
  • 3
  • 12
  • 27