[英]Revolution Slider jquery plugin inside Vue.js
I am trying to convert an html project into a vue app. 我正在尝试将html项目转换为vue应用。
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: 原始项目使用Revolution滑块的jquery插件,方法是通过html文件的body
标签内的script
标签添加它们,然后对其进行初始化:
<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? 向我的Vue项目添加革命滑块的最佳方法是什么?
I have installed jquery via npm and tried to import these scripts into the main.js entrypoint file. 我已经通过npm安装了jquery,并尝试将这些脚本导入main.js入口点文件。 I am not familiar with node or npm. 我对node或npm不熟悉。 Also when app loads, the jQuery is undefined inside these scripts raising errors in the console, which means there is something wrong. 同样,在加载应用程序时,这些脚本中的jQuery是未定义的,这会在控制台中引发错误,这意味着出了点问题。
最简单的方法可能是以相同的方式加载jquery(在这两个脚本标签之前)。
Import jQuery into your main.js and then set window.$ 将jQuery导入到main.js中,然后设置window。$
import $ from 'jquery'
window.$ = $
That will make it available globally so the scripts can use $
in the standard way. 这将使其在全球范围内可用,因此脚本可以以标准方式使用$
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.