Resolves an issue where appasset does not load resources when layout is disabled yii2

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.