标签:ar os java on 文件 ad as new javascript
php: //自定义数组参数 $newarr = array('a1' => 'a1', 'a2' => 'a2', 'a3' => 'a3'); $config = CJavaScript::encode($newarr); Yii::app()->clientScript->registerScript('customConfig', "var customConfig = " . $config . ";", CClientScript::POS_HEAD); //yii 自带配置文件 $yiiConfig = CJavaScript::encode(Yii::app()->params->toArray()); Yii::app()->clientScript->registerScript('appConfig',"var yiiConfig = " . $yiiConfig . ";", CClientScript::POS_HEAD); //分配变量 Yii::app()->clientScript->registerScript('myparam', 'var abc = "Hello"', CClientScript::POS_HEAD); js: alert(customConfig.a1); alert(yiiConfig.alert.msg); alert(abc);
ps : 虽然yii 也有这种类似功能,但是个人感觉还是没有druopal中实现的好!
标签:ar os java on 文件 ad as new javascript
原文地址:http://blog.csdn.net/wjc19911118/article/details/41946253