Home  >  Article  >  Web Front-end  >  How to load css and js files in yii2

How to load css and js files in yii2

零到壹度
零到壹度Original
2018-04-21 10:49:471813browse

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,[&#39;type&#39;=>&#39;text/css&#39;],&#39;test&#39;);
$js = <<<JS
    // console.log(&#39;sss&#39;);
JS;
$this->registerJs($js);

2. The view page is directly loaded with css and js files

$this->registerJsFile(&#39;@web/assets/9d00e06a/core.js&#39;);
$this->registerCssFile(&#39;@web/assets/9d00e06a/core.js&#39;);


##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

Write jsp files in Eclipse When, I found that js files and css files could not be loaded (to solve the problem that css files cannot be displayed in eclipse)

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn