Yii中加载css文件或js文件的方法
$cs=Yii::app()->clientScript;
 
//加载CSS文件
$cs->registerCssFile($cssFile);
 
//加载JS文件
$cs->registerScriptFile($jsFile);
 
//直接插入JS的方法:
$cs->registerScript(
 
'my-hello-world-1',
'var greetings = "Hello" + " " + "World";
alert(greetings);',
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.
若您觉得我的博文对您有帮助,欢迎点击下方按钮对我打赏
打赏