我想在category.tpl 中使用jQuery 插件。将文件放在 javascript/jquery 目录中。现在,如何使用这个插件?
最佳答案
/* one can load JS like that: */
if(file_exists('catalog/view/javascript/'.$this->config->get('config_template').'/script.js')) {
$this->document->addScript('catalog/view/javascript/'.$this->config->get('config_template').'/script.js');
}
使用现有函数比手动将脚本添加到 header.tpl 中更“正确”。
作为提示,根据下面的答案 - 人们可以循环文件名数组,以便控制加载顺序,这通常是相关的,但它们可能相互依赖。
关于php - 如何在Opencart中动态添加JavaScript?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12297083/