简体   繁体   English

Dragula已加载但无法正常工作

[英]dragula loaded but not working

I am developing an Alfresco surf page that uses dragula. 我正在开发一个使用Dragula的Alfresco冲浪页面。 As alfresco 5 uses dojo , i use dojo to load dragula library. 由于露天5使用dojo,所以我使用dojo加载dragula库。

 require(["${page.url.context}/res/components/js/dragula.js"], function(){
     dragula([document.getElementById('left-defaults')]);
 });

The library gets loaded ok but dragula is not being definded properly. 可以正常加载库,但未正确定义dragula。 If i try to use it, i get a not defined error in browser like this: 如果我尝试使用它,则会在浏览器中收到如下未定义的错误:

Uncaught ReferenceError: dragula is not defined
at extractar:388
at runFactory (dojo.js:1147)
at execModule (dojo.js:1275)
at dojo.js:1310
at guardCheckComplete (dojo.js:1290)
at checkComplete (dojo.js:1305)
at onLoadCallback (dojo.js:1471)
at HTMLScriptElement.onLoad (dojo.js:1720).

Some pics of my problem. 我的问题的一些照片。

dragula library loaded ok 德拉古拉图书馆装好

dragula browser error Dragula浏览器错误

why is this happening? 为什么会这样呢? Do i have to use another way to load and use dragula? 我是否必须使用另一种方式来加载和使用Dragula?

Thanks in advance 提前致谢

Your code is missing formal parameter passed to callback function ie 您的代码缺少传递给回调函数的形式参数,即

require(["path/to/dragula.js"], function(dragula /*this is missing*/) {
    // you can use dragula param here
    ...
});

Look at the dojo.require to observe that if you want refer to module loaded at N-th index in array passed as first param to require() you need to provide formal parameters matching first N modules in array. 查看dojo.require,以观察是否要引用作为第一个参数传递给require()数组中第N个索引加载的模块,您需要提供与数组中前N个模块匹配的形式参数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM