如何将外部javascript文件添加到Zend Framework 2应用程序? [英] How to add an external javascript file to a Zend Framework 2 application?

查看:65
本文介绍了如何将外部javascript文件添加到Zend Framework 2应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将jQuery和其他javascript文件添加到我的Zend Framework项目中。我正在尝试使用Action控制器: -

I need to add jQuery and other javascript files to my Zend Framework project. I am trying to do it with an Action controller:-

public function userinfoAction()
{   
    $this->view->headScript()->appendFile($basePath .'/js/validate_jquary.js');
    $this->headScript()->appendFile('http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js'); 
    return new ViewModel();
}

但它不起作用。

推荐答案

 $this->HeadScript()->appendFile('http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js','text/javascript');
 $this->HeadScript()->appendFile('http://localhost/zend/public/js/validate_jquary.js','text/javascript');

在视图中使用此代码即可。但我不知道这是正确的方法。

It is OK with this code in the view. But I don't know is this correct method.

这篇关于如何将外部javascript文件添加到Zend Framework 2应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆