- 浏览: 3333107 次
- 性别:
- 来自: 北京
-
文章分类
- 全部博客 (567)
- Web前端-html/表单 (19)
- Web前端-CSS (24)
- Web前端-CSS框架 (4)
- Web前端-JS语言核心 (50)
- Web前端-JS客户端 (26)
- nodejs生态+grunt (10)
- seajs和requirejs (9)
- backbone等框架 (7)
- 模板基础 (7)
- Web前端-deps(不改动) (6)
- Web前端-component (10)
- Web前端-jquery-plugin (13)
- 浏览器兼容性 (6)
- Web前端-使用jQuery (25)
- Web前端-使用jqueryui (6)
- Web前端-性能优化 (3)
- Web协议-HTTP (6)
- ExtJS (13)
- PHP (22)
- PHP面向对象 (4)
- PHP扩展-SOAP (6)
- PHP扩展-curl (4)
- PHP与HTML(导出) (5)
- PHP扩展-综合 (7)
- mysql基础应用 (18)
- 技术心情 (18)
- 算法和面试题 (17)
- 工具(开发)使用 (36)
- memcached原理 (2)
- session和cookie (4)
- UML (2)
- Web前端_FusionCharts (5)
- Web前端_Flex (4)
- Web前端_JSP (3)
- JavaSE (10)
- JavaEE (4)
- tomcat (2)
- Servlet开发 (3)
- Spring开发 (1)
- REST相关 (2)
- 大访问量、高并发 (2)
- 网络编程 (1)
- YII (21)
- linux命令和内核 (12)
- yii与数据库 (10)
- yii与表单 (12)
- yii view层 (1)
- perl (7)
- yii扩展 (7)
- shell (4)
- photoshop (7)
- 视觉设计 (2)
- 我关注的名人在路上 (4)
- 1-自学能力 (1)
- 2-人际沟通能力 (3)
- 3-职业规划能力 (7)
- 4-项目管理能力 (2)
- python (3)
- django (4)
- Mysql高级应用 (6)
- prototype.js (4)
- Web系统安全 (1)
- Web前端-mobile (2)
- egret (6)
- jQuery源码分析 (5)
- fis (4)
最新评论
-
yzq21056563:
感谢作者分享~请教下,http://www.lisa33xia ...
CSS基础:text-overflow:ellipsis溢出文本 -
u012206458:
$.ajax的error,complete,success方法 -
DEMONU:
谢谢,虽然不能给你赞助,但是要给你顶
mysql中key 、primary key 、unique key 与index区别 -
njupt_tolmes:
阿凡达阿凡达阿凡达阿凡达阿凡达阿凡达阿凡达阿凡达阿凡达阿滕庆亚 ...
CSS基础:text-overflow:ellipsis溢出文本 -
zenmshuo:
用过SpreadJS,也包含数据可视化的图表
推荐几个web中常用js图表插件
作者:zccst
四、在视图层(../views/..)添加CSS文件或JavaScript文件
批注1:在视图层引用与在控制层引用的方式一样。但在视图层中引用加载的要晚一些。
批注2:引用路径是使用baseUrl,而不是basePath。
批注3:关于参数CClientScript::POS_END,作用是延时加载,提高页面渲染效率。例如:
Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . "/js/jqueryui/jquery-ui.min.js", CClientScript::POS_END);
全部参数一览:
CClientScript::POS_HEAD : the script is inserted in the head section right before the title element.
CClientScript::POS_BEGIN : the script is inserted at the beginning of the body section.
CClientScript::POS_END : the script is inserted at the end of the body section.
CClientScript::POS_LOAD : the script is inserted in the window.onload() function.
CClientScript::POS_READY : the script is inserted in the jQuery's ready function.
注:这些参数仅适用于加载js文件,不适用于加载css文件。
三、引入jquery核心部件
批注:不论在页面中的何种位置引用,最终yii会将jquery.js文件放入yii的assets文件夹下。即/projectName/assets/82qg58/jquery-1.6.1.min.js。
二、在控制层(../controllers/xxController.php)添加CSS文件或JavaScript文件
新增:
在控制层,还可以在ActionIndex中引入,而且还可以引入别的module文件夹中的js/css文件。甚至是任意文件夹下的js/css文件
一、在../layouts/main.php中引入
1,直接引入
2,yii方式引入
批注:在yii运行后,第一种在head中,第二种在body最后面,显然后者效率更高。但必须加载的js和css有必要写在head中。
3,区别
批注:至于为什么会有/assets/b729ab/js/jquery.js这样的文件生成,还在继续探索中。
如果您觉得本文的内容对您的学习有所帮助,您可以微信:
四、在视图层(../views/..)添加CSS文件或JavaScript文件
Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . "/js/TableView.js"); Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . "/js/datechooser.js"); Yii::app()->clientScript->registerCssFile(Yii::app()->baseUrl . "/css/datechooser.css");
批注1:在视图层引用与在控制层引用的方式一样。但在视图层中引用加载的要晚一些。
批注2:引用路径是使用baseUrl,而不是basePath。
批注3:关于参数CClientScript::POS_END,作用是延时加载,提高页面渲染效率。例如:
Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . "/js/jqueryui/jquery-ui.min.js", CClientScript::POS_END);
全部参数一览:
CClientScript::POS_HEAD : the script is inserted in the head section right before the title element.
CClientScript::POS_BEGIN : the script is inserted at the beginning of the body section.
CClientScript::POS_END : the script is inserted at the end of the body section.
CClientScript::POS_LOAD : the script is inserted in the window.onload() function.
CClientScript::POS_READY : the script is inserted in the jQuery's ready function.
注:这些参数仅适用于加载js文件,不适用于加载css文件。
三、引入jquery核心部件
Yii::app()->clientScript->registerCoreScript('jquery');
批注:不论在页面中的何种位置引用,最终yii会将jquery.js文件放入yii的assets文件夹下。即/projectName/assets/82qg58/jquery-1.6.1.min.js。
二、在控制层(../controllers/xxController.php)添加CSS文件或JavaScript文件
public function init() { //parent::init(); Yii::app()->clientScript->registerCssFile(Yii::app()->baseUrl.'/css/my.css'); Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl.'/css/my.js'); }
新增:
在控制层,还可以在ActionIndex中引入,而且还可以引入别的module文件夹中的js/css文件。甚至是任意文件夹下的js/css文件
public function actionIndex(){ $modify,$reg = some_value; $js = $this->renderFile($this->getInstallViewPath(). '/asset/install.js',array('reg_mp'=>$reg), true); $js = $this->renderFile($this->getViewPath() . '/assets/install_params.js', array('modify' => $modify), true); $cs = Yii::app()->clientScript; $cs->registerScript('asset/install', $js, CClientScript::POS_END); $cs->registerCssFile(Yii::app()->baseUrl . '/css/launch_feed.css'); $cs->registerScript('assets/install_params',$js,CClientScript::POS_END); $cs->registerScriptFile(Yii::app()->baseUrl . '/resources/jquery.form.js'); $cs->registerCssFile(Yii::app()->baseUrl . '/css/install_params.css'); $this->render('xxx'); } public function getInstallViewPath() { return $this->getModule()->getBasePath().'/../operations/views'; }
一、在../layouts/main.php中引入
1,直接引入
<!-- css --> <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/print.css" media="print" /> <!-- 图片 --> <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/js/autocomplete/indicator.gif" /> <!-- js --> <script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/js/jquery.js"></script>
2,yii方式引入
<?php <!-- (一)简单用法 --> <!-- js --> Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . "/js/jqueryui/jquery-ui.min.js", CClientScript::POS_END); <!-- (二)复杂用法 --> if($this->user->id) { Yii::app()->clientScript->registerScriptFile(Yii::app()->createUrl('/account/info', array('format' => 'js')), CClientScript::POS_END); } if($this->user->id) { Yii::app()->clientScript->registerScriptFile(Yii::app()->createUrl('site/baseJs')); } ?>
批注:在yii运行后,第一种在head中,第二种在body最后面,显然后者效率更高。但必须加载的js和css有必要写在head中。
3,区别
批注:至于为什么会有/assets/b729ab/js/jquery.js这样的文件生成,还在继续探索中。
如果您觉得本文的内容对您的学习有所帮助,您可以微信:

发表评论
-
Yii隐藏index.php文件的步骤
2014-06-14 14:03 12054作者:zccst 1.修改Apache的配置httpd.co ... -
YII异常处理actionError
2014-06-14 08:47 2004zccst转 错误处理目录 1,引发异常 2,显示错误 3, ... -
YII之 redirect 与contoller之间的方法调用
2014-05-31 18:44 11406作者:zccst 一个contoller里怎么调用另一个co ... -
yii中设置默认时区和语言
2013-04-24 16:28 3543作者:zccst 把php从5.2升级到5.4后,发现5. ... -
Yii异常解决办法
2013-04-23 17:15 1199作者:zccst 在Yii的项目中有一个../protect ... -
Yii之HttpRequest相关
2012-08-16 18:35 5135作者:zccst yii中的HttpRequest很像Jav ... -
yii之Log(日志)使用
2012-06-07 19:17 24986作者:zccst Yii 提供了 ... -
Yii之urlManager相关
2012-03-31 13:04 7130作者:zccst 首先urlManager是CUrlMan ... -
yii框架的执行过程
2012-03-11 14:09 3793作者:zccst 二、controllers里的$this ... -
Yii中引入module
2012-03-11 14:06 4989作者:zccst 一、controller与layout/ ... -
Yii->user(当前用户)相关
2012-03-02 17:50 21718作者:zccst 常用的用法是 class Contro ... -
如何在纯js文件中设置yii方式的url地址
2012-02-20 20:56 3354作者:zccst 1,在siteController.ph ... -
Yii使用filter进行访问控制
2012-02-16 19:23 15037Yii使用filter进行访问控制 作者:zccst 在Co ... -
Yii控制层处理结果返回前端的三种方式(render)
2012-01-12 16:28 31403Yii控制层处理结果返回前端的三种方式 作者:zccst ... -
Yii之widget专题
2012-01-12 16:14 11572作者:zccst 关于widgets ... -
Yii中使用session防止重复提交
2012-01-09 12:13 3228表单提交时,由于网速等原因,会出现重复提交的现象。 一、从前 ... -
Yii设置分页
2011-12-11 16:41 46371,在../models/NewDemand.php中定义pa ... -
在yii中使用session和cookie
2011-12-08 09:41 17338作者:zccst 2014-6-10 yii 操作sess ... -
Yii中引入php文件及插件
2011-11-03 14:32 24597作者:zccst 一、设置环境变量(在PHP) echo g ... -
YII初步
2011-06-03 22:19 2419安装过程,文档里有。 一、搭建Yii环境可能遇到的问题 1, ...
评论