Yii 框架禁用layout后 css,js文件加载问题

写yii的项目时,写一个单独的页面.不需要公共的头尾,
在控制器里写上
$this->layout=false;
或者
在视图中

<?php
use module\assets\AppAsset
AppAsset::register($this);
$this->context->layout = false;
?>

显示视图之后发现css,js文件均未加载
查阅资料后可以用$this->beginPage()引入

<?php
use module\assets\AppAsset
AppAsset::register($this);
$this->context->layout = false;
?>
<?php $this->beginPage(); ?> 
<!DOCTYPE html>
<html lang="en">
<title>Blank</title>
<?php $this->head(); ?>
</head>
<body>
<?php $this->beginBody(); ?> 
……
<?php $this->endBody(); ?> 
</body>
</html>
<?php $this->endPage(); ?>    /

正常显示

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容