如何为 Mediawiki 标签扩展加载 css?
How do you load the css for a Mediawiki tag extension?
如何加载扩展程序的 css?
使用 Mediawiki 1.25.2,我复制了 boiler plate extension 并编辑了 extension.json 以包含
"Hooks": {
"BeforePageDisplay": [
"FinancialMathematicsHooks::onBeforePageDisplay"
],...
},
"ResourceModules": {
"ext.FinancialMathematics": {
"styles": [
"modules/ext.FinancialMathematics.css"
]
}
}
并在我添加的挂钩文件中
public static function onBeforePageDisplay( OutputPage &$out, Skin &$skin ) {
$out->addModuleStyles( 'ext.FinancialMathematics' );
return true;
}
但扩展名不包括 css。
扩展已安装on a wiki here and the complete code for the extension is on github
您应该检查模块是否正确加载。最简单的方法是使用浏览器的控制台和 运行 以下命令:
mw.loader.getState("ext.FinancialMathematics");
您将在带有给定模块 error
的页面上获得一个状态。因此检查加载请求的输出(使用浏览器的网络选项卡或使用 direct load.php url)。您将获得一个带有起始注释的输出,其中显示 Internal Error
。因此,请检查服务器上的错误日志以查看完整的错误消息和堆栈跟踪以调试此错误。
如何加载扩展程序的 css?
使用 Mediawiki 1.25.2,我复制了 boiler plate extension 并编辑了 extension.json 以包含
"Hooks": {
"BeforePageDisplay": [
"FinancialMathematicsHooks::onBeforePageDisplay"
],...
},
"ResourceModules": {
"ext.FinancialMathematics": {
"styles": [
"modules/ext.FinancialMathematics.css"
]
}
}
并在我添加的挂钩文件中
public static function onBeforePageDisplay( OutputPage &$out, Skin &$skin ) {
$out->addModuleStyles( 'ext.FinancialMathematics' );
return true;
}
但扩展名不包括 css。
扩展已安装on a wiki here and the complete code for the extension is on github
您应该检查模块是否正确加载。最简单的方法是使用浏览器的控制台和 运行 以下命令:
mw.loader.getState("ext.FinancialMathematics");
您将在带有给定模块 error
的页面上获得一个状态。因此检查加载请求的输出(使用浏览器的网络选项卡或使用 direct load.php url)。您将获得一个带有起始注释的输出,其中显示 Internal Error
。因此,请检查服务器上的错误日志以查看完整的错误消息和堆栈跟踪以调试此错误。