Javascript 仅在Tampermonkey中导入库(通过@require)时出错
我想在我的Tampermonkey脚本中导入,但我收到了此错误(jQuery已经在我的网站中): [错误]错误:执行脚本“DragTable”失败!未定义的是 不是函数(靠近“…$.widget…”)错误(匿名函数) (userscript.html:2:186) 这是我的剧本:Javascript 仅在Tampermonkey中导入库(通过@require)时出错,javascript,tampermonkey,Javascript,Tampermonkey,我想在我的Tampermonkey脚本中导入,但我收到了此错误(jQuery已经在我的网站中): [错误]错误:执行脚本“DragTable”失败!未定义的是 不是函数(靠近“…$.widget…”)错误(匿名函数) (userscript.html:2:186) 这是我的剧本: // ==UserScript== // @name DragTable // @namespace http://tampermonkey.net/ // @version 0.1 /
// ==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==
如何导入它而不出错?Tks请参见,该库同时需要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==
但是,请参见。似乎您也需要导入jquery。我的网站已经有了它