未加载YII2登录资产CSS

时间:2019-04-26 03:08:27

标签: yii2 assets

我创建了登录资产和登录布局。为什么登录页面没有加载CSS文件?

class LoginAsset extends AssetBundle {

public $basePath = '@webroot';
public $baseUrl = '@web';
public $css = [
    'gent/css/bootstrap.min.css',
    'gent/css/font-awesome.min.css',
    'gent/css/nprogress.css',
    'gent/css/animate.min.css',
    'gent/css/custom.min.css"',
];
public $js = [
];
public $depends = [
    'yii\web\YiiAsset',
    'yii\bootstrap\BootstrapAsset',
];

}

public function actionLogin() {
    $this->layout = 'login';
    return $this->render('login', [
                'model' => $model,
    ]);
}

<?php

/**
 * @var string $content
 * @var \yii\web\View $this
 */
use app\assets\LoginAsset;
use yii\helpers\Html;

LoginAsset::register($this);
?>
<?php $this->beginPage(); ?>
<!DOCTYPE html>
<html lang="<?= Yii::$app->language ?>">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta charset="<?= Yii::$app->charset ?>" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        <?= Html::csrfMetaTags() ?>
        <title>QAMETWIS</title>
        <?php $this->head() ?>

    </head>
    <body class="login">
        <?php echo $content ?>
    </body>


</html>
<?php $this->endPage(); ?>

这是登录页面。

enter image description here

1 个答案:

答案 0 :(得分:1)

编辑以下部分:(添加beginBody)

<body>
<?php $this->beginBody() ?>

  # Code ...

<?php $this->endBody() ?>
</body>