【发布时间】:2019-11-23 13:07:16
【问题描述】:
我目前正在我的 symfony 应用程序上迁移到 webpack-encore,我正在努力使用 jquery-ui 库。
在我的第一个文件app.js 我想使用缓动
import $ from 'jquery';
import 'bootstrap';
import 'jquery-ui/ui/effect';
// Smooth scrolling using jQuery easing
$('a.js-scroll-trigger[href*="#"]:not([href="#"])').click(function () {
if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
if (target.length) {
$('html, body').animate({
scrollTop: (target.offset().top - 70)
}, 1000, "easeInOutExpo");
return false;
}
}
});
我花了一些时间才弄清楚它在jqueryui/ui/effect.js 文件中....
现在在我的view.js 我想使用可拖动元素:
//css
import '../css/event.css';
//js
import $ from 'jquery';
import 'bootstrap';
import 'jquery-ui/ui/plugin';
$("span[class='draggable']").draggable({
snap : '.dropdown'
});
当然它不起作用我得到一个
错误:$("span[class='draggable']").draggable() 不是函数
有没有合适的方法来加载所有的 jquery-ui 就像整天好?用一个简单的
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js"></script>
【问题讨论】:
标签: symfony webpack webpack-encore