首页 > 解决方案 > 如何注册 Prestashop 组件 JavaScript 文件?

问题描述

我希望在 prestashop 1.7 中注册一个 Javascript 文件。

我想用registerJavascript()这个。

该文件位于“themes/new-theme/js/components/choice-table.js”中。

但我的代码不起作用:

  public function hookHeader($params)
    {
        $this->context->controller->registerJavascript(
            'choice-table',
            'themes/new-theme/js/components/choice-table.js',
            [
                'priority' => 150,
                'position' => 'bottom',
                'attribute' => 'defer'
            ]
        );
    }
}

任何想法?

标签: phpsymfonyprestashophook

解决方案


我最终不得不将文件 'choice-table.js' 与 webpack 捆绑在一起。


推荐阅读