如何使用webpack正确管理jquery-ui

我目前正在我的symfony应用程序上转到webpack-encore,并且在jquery-ui库中苦苦挣扎。

在我的第一个文件DeclARE @spid integer; DeclARE spids CURSOR FOR SELECT session_id FROM msdb.sys.dm_exec_sessions WHERE nt_user_name NOT IN (/*White List of Logins*/ 'sa'); OPEN spids FETCH NEXT FROM spids INTO @spid WHILE @@FETCH_STATUS = 0 BEGIN KILL @spid; FETCH NEXT FROM spids INTO @spid END; CLOSE spids; DEALLOCATE spids; 中,我想使用缓动

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

当然得到了

  

错误:$(“ span [class ='draggable']”)。draggable()不是函数

是否有适当的方式来像往常一样加载所有jquery-ui?简单

//css
import '../css/event.css';

//js 
import $ from 'jquery';
import 'bootstrap';
import 'jquery-ui/ui/plugin';

$("span[class='draggable']").draggable({
    snap : '.dropdown'
});
liuyun050229 回答:如何使用webpack正确管理jquery-ui

此代码已通过测试

安装jquery-ui参考:doc

$ npm install webpack-jquery-ui

然后

require('webpack-jquery-ui/draggable');

$( "#draggable" ).draggable();
本文链接:https://www.f2er.com/3045713.html

大家都在问