Include CSS,javascript file in Yii Framework

前端 未结 18 1829
[愿得一人]
[愿得一人] 2020-11-29 15:46

How to include a Javascript or CSS file in Yii Framework?

I want to create a page on my site that has a little Javascript application running, so I want to include <

18条回答
  •  醉酒成梦
    2020-11-29 15:48

    Easy in your conf/main.php. This is my example with bootstrap. You can see that here

    'components'=>array(
        'clientScript' => array(
            'scriptMap' => array(
                'jquery.js'=>false,  //disable default implementation of jquery
                'jquery.min.js'=>false,  //desable any others default implementation
                'core.css'=>false, //disable
                'styles.css'=>false,  //disable
                'pager.css'=>false,   //disable
                'default.css'=>false,  //disable
            ),
            'packages'=>array(
                'jquery'=>array(                             // set the new jquery
                    'baseUrl'=>'bootstrap/',
                    'js'=>array('js/jquery-1.7.2.min.js'),
                ),
                'bootstrap'=>array(                       //set others js libraries
                    'baseUrl'=>'bootstrap/',
                    'js'=>array('js/bootstrap.min.js'),
                    'css'=>array(                        // and css
                        'css/bootstrap.min.css',
                        'css/custom.css',
                        'css/bootstrap-responsive.min.css',
                    ),
                    'depends'=>array('jquery'),         // cause load jquery before load this.
                ),
            ),
        ),
    ),
    

提交回复
热议问题