- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在我的 Joomla 组件中,我根据 phpstorm is $document->addStyleSheet deprecated 添加了一个样式表。
这是我使用的代码:
$uri = JUri::base();
$document = JFactory::getDocument();
$document->addStyleSheet(JUri::base() . "components/com_exampe/views/stats/tmpl/style.css");
我也试过这段代码:
JHtml::stylesheet('com_hccxmlkadernet/views/statistiek/tmpl/style.css', array(), true);
但这也被弃用了
有人能告诉我正确的方法是什么吗?
最佳答案
根据这个页面: https://api.joomla.org/cms-3/classes/Joomla.CMS.Document.Document.html#method_addStyleSheet
上面写着 addStyleSheet() 已弃用。实际上整个方法并没有被弃用,只是预期的参数略有改变。
v4.0 (url, mime, media, attribs) method signature is deprecated, use (url, options, attributes) instead.
所以,只要你用;
$document->addStyleSheet($url)
您无需担心任何事情,一切顺利(因为 arg1 在两个版本中都是 $url)。
不要使用 JHTML。它已在 J2.5 中弃用并从 J3.x 中删除:
It used to be possible to do this with JHTML, however, this was deprecated in Joomla 2.5 and removed in Joomla 3.x.
引用:https://docs.joomla.org/J3.x:Adding_JavaScript_and_CSS_to_the_page
关于css - $document->addStyleSheet 弃用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52517838/
在我的 Joomla 组件中,我根据 phpstorm is $document->addStyleSheet deprecated 添加了一个样式表。 这是我使用的代码: $uri = JUri::
我正在开发模板,并且正在使用客户端 JavaScript 编译器处理 .less 文件。此编译器需要 rel="stylesheet/less" 属性来了解要编译的内容。 所以我有这段代码: $doc
我想通过以下来源将 css 和 js 文件添加到我的模板 joomla3.4:但是,当我运行 joomla temp 时,在 fire fox view source 网页中,bootsrap 和 j
我正在尝试为 joomla 2.5 创建模块,但我有错误需要大家帮助我。我在 tmpl/default.php 文件中有脚本: defined('_JEXEC') or die; $baseurl =
我是一名优秀的程序员,十分优秀!