Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mobile 如何在移动版本中将js文件加载到prestashop_Mobile_Prestashop - Fatal编程技术网

Mobile 如何在移动版本中将js文件加载到prestashop

Mobile 如何在移动版本中将js文件加载到prestashop,mobile,prestashop,Mobile,Prestashop,我想加载一些js文件到移动版的prestashop模块,这个问题只发生在移动版,我有这个代码 public function install() { return parent :: install() && $this->registerHook('displayCenterleftColumn') && {foreach from=$js_files item=js_uri} <script type="text/java

我想加载一些js文件到移动版的prestashop模块,这个问题只发生在移动版,我有这个代码

 public function install() {
    return parent :: install()
    && $this->registerHook('displayCenterleftColumn') &&   
{foreach from=$js_files item=js_uri}
<script type="text/javascript" src="{$js_uri}"></script>
{/foreach}
$this->registerHook('Header'); }

header.tpl中的其他问题有以下代码

 public function install() {
    return parent :: install()
    && $this->registerHook('displayCenterleftColumn') &&   
{foreach from=$js_files item=js_uri}
<script type="text/javascript" src="{$js_uri}"></script>
{/foreach}
{foreach from=$js\u files item=js\u uri}
{/foreach}
在哪里可以设置$js_files变量


谢谢。

首先,卸载新模块

其次,将此代码放入您的模块中:

function install() {
    if (!parent::install())
        return false;
    if (!$this->registerHook('displayCenterleftColumn'))
        return false;
    if (!$this->registerHook('header'))
        return false;
    return true;
}
第三,再次安装您的模块

您的问题是在安装函数中使用了“Header”,这是一个不正确的值。正确的值为“header”


祝你好运

我解决了这个问题,在模块安装文件中添加了displayhookMobile函数

public function     hookdisplayMobileHeader($params) in which i assigned my js and css file

 public function    hookdisplayMobileHeader($params){
$this->context->controller->addJS(_MODULE_DIR_."blockcart/ajax-cart.js");
$this->context->controller->addJS(($this->_path).'front/js/functions.js');
$this->context->controller->addJS(($this->_path).'front/js/main.js');
$this->context->controller->addJS(($this->_path).'front/js/jquery.validate.js'); 
}

它不能解决问题,我希望它在移动设备中工作,在计算机版本中没有问题。试试这个:。验证页面中是否加载了所有js和css文件。路径可能与主题不同。js和css负载必须注入模块安装文件中的hookdisplayMobileHeader中,才能在移动应用程序中工作