1 加载css
$cssString = ".gray-bg{color:red;}";
$this->registerCss($cssString);
2 加载js块
<?php $this->beginBlock('test') ?>
$(function($) {
alert('hello');
});
<?php $this->endBlock() ?>
<?php $this->registerJs($this->blocks['test'], \yii\web\View::POS_END); ?>
或者另一种方式
<?php
$this->registerJs(
'
alert('hello word');
'
);
?>