【发布时间】:2020-06-19 01:29:09
【问题描述】:
按照MediaWiki.org 上的教程,我尝试使用用户脚本自定义工具栏;但是,有时当我从 common.js 加载它时,我在控制台中收到此错误:
jQuery.Deferred exception: $(...).wikiEditor is not a function TypeError: $(...).wikiEditor is not a function
at quickMAR_add (https://en.moegirl.org/index.php?title=User:Leranjun/quickMAR.js&action=raw&ctype=text/javascript:52:19)
at https://en.moegirl.org/index.php?title=User:Leranjun/quickMAR.js&action=raw&ctype=text/javascript:60:12
at mightThrow (https://en.moegirl.org/load.php?debug=false&lang=en&modules=jquery%2Cmediawiki&only=scripts&skin=vector&version=1o54dq6:49:598)
at process (https://en.moegirl.org/load.php?debug=false&lang=en&modules=jquery%2Cmediawiki&only=scripts&skin=vector&version=1o54dq6:50:269) undefined
更奇怪的是,它有时有效,有时无效……如果我将代码复制/粘贴到控制台并手动执行,它总是有效。
如果需要,源代码是here。
【问题讨论】:
-
如果您的脚本在
wikiEditorjQuery 插件注册之前运行,您只会收到此错误。我们需要查看上面包含 jQuery、插件和脚本的 HTML -
@Phil 我很抱歉,但我不知道您所说的 HTML 和插件是什么意思。你是说编辑页面吗?
-
@frankly.not.frank 你能把这个html页面添加到顶部吗
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> -
@AlwaysHelping Oopsies,忘了说我不是管理员,不能进行全局更改。更重要的是,其他jQuery函数功能齐全,所以我很确定jQuery已经包含在内了。
标签: javascript jquery mediawiki wikitext