The king sent me to patrol the mountains _site:http://blog.csdn.net/wang78699425/article/details/52369841
Recently because of the project (a project in yii2) need, the login page does not need to use layout, a separate page, and then I put a line of code in the login view $this->context->layout = false to disable layout, while using module\assets\AppAsset::register($this) to load resources (CSS, JS, etc.), refresh the page, found that CSS, JS all did not load in, Meng forced ~.
Later debugging for half a day, found to be introduced through, and $this->beginPage() only in the view to add a few required code, resources will be introduced, the code is as follows:
<?phpmodule\assets\appasset::register ($this); $this->context->layout = false;? ><?php $this->beginpage () ?> <--required--> <?php $this->beginbody () ?> <--required--><--View code block--<?php $this->endbody () ?> <--required--></body><?php $this->endpage () ?> <--required-- >
Resolves an issue where appasset does not load resources when layout is disabled yii2