属性“CWebApplication.clientScript”是只读的

时间:2013-11-14 09:29:35

标签: php yii

控制器

   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;是只读的。

1 个答案:

答案 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/