Yii2--禁用layout后引入Js、Css

想去掉layout , 使用 $this->layout = false 之后,页面上通过CommonAsset::register($this)引入的Js、Css都没有了,解决方法如下:


use backend\assets\CommonAsset;
CommonAsset::register($this);
?>
 $this->beginPage()?>//必需

<html lang="UTF-8">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no" />
    <title>title>
     $this->head() ?>//必需

    <meta name="author" content="">
head>
<body>
 $this->beginBody() ?>//必需
<div class="container">
div>
 $this->endBody() ?>//必需
body>
html>
 $this->endPage() ?>//必需

你可能感兴趣的:(个人笔记,YII2)