javascript-仅在Tampermonkey中导入库(通过@require)时出错

我想在我的Tampermonkey脚本中导入dragtable.js,但出现此错误(jQuery已在我的网站中):

[Error] ERROR: Execution of script ‘DragTable’ failed! undefined is
not a function (near ‘…$.widget…’) error (anonymous function)
(userscript.html:2:186) … …

这是我的脚本:

// ==UserScript==
// @name         DragTable
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        http://localhost:9010/*
// @require https://rawgit.com/akottr/dragtable/master/jquery.dragtable.js

// @grant        none
// ==/UserScript==

如何导入而不会出现错误? ks

最佳答案
参见dragtable‘s ReadMe,该库需要jQuery和jQuery UI.

从列出的错误看来,jQuery UI似乎不存在.

因此,您的脚本至少应为:

// ==UserScript==
// @name        DragTable,getting started
// @match       http://localhost:9010/*
// @require     http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.1/jquery-ui.min.js
// @require     https://rawgit.com/akottr/dragtable/master/jquery.dragtable.js
// @grant        none
// ==/UserScript==

但是,请参见this other Q&A for a more details about jQuery UI in a userscript.

相关文章

kindeditor4.x代码高亮功能默认使用的是prettify插件,prett...
这一篇我将介绍如何让kindeditor4.x整合SyntaxHighlighter代...
js如何实现弹出form提交表单?(图文+视频)
js怎么获取复选框选中的值
js如何实现倒计时跳转页面
如何用js控制图片放大缩小