37590
- 37590 赞了回复
在view中这样加载js方法
<script> <?php $this->beginBlock('js_end') ?> function jsfunction() { //jscode } <?php $this->endBlock() ?> </script> <?php $this->registerJs($this->blocks['js_end'], \yii\web\View::POS_END); ?>
可以写多个block,随意放置在头部或者底部,具体位置请看
\yii\web\View
类