我刚刚在React中安装了jquery-slimscroll插件,当我运行
$('.sk-hits-grid-hit').eq(1).slimScroll({
height: '26em'
});在我的控制台中,它可以正常工作,但它不能在我的应用程序中运行。它没有在我的应用程序中给我任何错误,它只是没有做任何事情。我还检查了开发人员工具中的‘网络’标签和所有正确导入的文件。
这是我的index.html:
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js">
</script>
<script type="text/javascript" src="node_modules/jquery-slimscroll/jquery.slimscroll.min.js"></script>
</head>
...这是我的index.tsx:
var $ = require("jquery");
import 'jquery-waypoints/waypoints.min.js'; //Waypoints trigger functions when you scroll to an element
import 'jquery/dist/jquery.min.js'; //Allows jQuery functionality
import 'bootstrap/dist/js/bootstrap.min.js'; //Front-end framework to help display webpage
import 'jquery-slimscroll/jquery.slimscroll.min.js';
...
$( document ).ready(function() {
$('.sk-hits-grid-hit').eq(1).slimScroll({
height: '26em'
});
})有什么想法吗?我试着把我的脚本移到我的body标签上,但是没有任何改变。
发布于 2017-08-01 03:33:01
似乎是引用问题,请尝试将路径更改为第二个引用:
"node_modules/jquery-slimscroll/jquery.slimscroll.min.js"在不知道您的文件路径的情况下,我可以建议尽可能多的内容
https://stackoverflow.com/questions/45423551
复制相似问题