属性“CWebApplication.clientScript”是只读的


Property "CWebApplication.clientScript" is read only

Contoller

   public function actionSend(){
        Yii::app()->clientScript->registerCoreScript('myplugin');
        $this->render();
       echo 'submit';
   }

主.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"是只读的。

你必须

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/