Home >Web Front-end >JS Tutorial >How to load css and js files in yii2
This article introduces the method of loading css and js files in yii2, which has certain reference value. Now I share it with you. Friends in need can refer to it
1 . The view page is loaded directly
$css = <<<CSS p {text-indent:5em;} p{width: 500px;} CSS; $this->registerCss($css,['type'=>'text/css'],'test'); $js = <<<JS // console.log('sss'); JS; $this->registerJs($js);
2. The view page is directly loaded with css and js files
$this->registerJsFile('@web/assets/9d00e06a/core.js');
$this->registerCssFile('@web/assets/9d00e06a/core.js');
##Related recommendations:
Yii2.0 flexibly uses AppAssets to manage CSS styles and JS scripts
Yii2 loads our own css and js files [small Tips]
YII2 framework references js and css files
YII2 introduces js/css files in the view
The above is the detailed content of How to load css and js files in yii2. For more information, please follow other related articles on the PHP Chinese website!