gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 10:56:45 26 4
gpt4 key购买 nike

我要导入dragtable.js在我的 Tampermonkey 脚本中,但出现此错误(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==

如何在不出错的情况下导入它?谢谢

最佳答案

参见 dragtable's ReadMe ,该库需要 jQueryjQuery 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 .

关于javascript - 在 Tampermonkey 中导入库(通过@require)时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55601156/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com