<script> <!-- 编写script标签是为了编辑器识别js代码,可以省略 -->
<?php
$this
->beginBlock('js_end') ?>
...
js code...
<?php
$this
->endBlock(); ?>
</script>
<?php
$this
->registerJs(
$this
->blocks['js_end'],\yii\web\View::POS_END);//将编写的js代码注册到页面底部 ?>
view中引入css/js的方法:
$this->registerJs();
$this->registerJsFile();
$this->registerCss();
$this->registerCssFile();
或
use yii\web\View;
$view = new View();
$view->registerJs();

