控制器
public function actionSend(){
Yii::app()->clientScript->registerCoreScript('myplugin');
$this->render();
echo 'submit';
}
main.php
'clientScript' =>array(
'packages'=>array(
'myplugin'=>array(
'baseUrl'=>'myload/',
'js'=>array('myload/bow.js'),
),
'boot'=>array( //set others js libraries
'baseUrl'=>'myload/',
'js'=>array('myload/bow2.js'),
'css'=>array( // and css
// 'css/bootstrap.min.css',
// 'css/custom.css',
// 'css/bootstrap-responsive.min.css',
),
'depends'=>array('myplugin'), // cause load myplugin before load this.
)
) )
错误:
属性" CWebApplication.clientScript#34;是只读的。
答案 0 :(得分:4)
您必须将clientScript
放在components
内,如:
'components'=>array(
'clientScript' => array(
//something depend on your configure
),
),
此外,此链接对您有用:http://www.yiiframework.com/forum/index.php?/topic/1421-where-to-put-javascript-file/