1

控制器

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

主文件

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

4

1 回答 1

5

你必须像这样放在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/

于 2013-11-14T10:36:36.853 回答