Yii2 assest Bundle 未在视图中加载 CSS



我遇到了一个问题。我有自定义模块,我正在尝试通过 AppAsset 加载 CSS 和 JS,但它没有加载。

在我的模块中,我有布局文件夹,我正在尝试在其中访问 appasset 并注册视图,但它没有加载。甚至资产包也显示正在加载屁股

告诉我我做错了什么。代码如下

namespace appassets;
use yiiwebAssetBundle;

class AppAsset extends AssetBundle
{
public $basePath = '@webroot';
public $baseUrl = '@web';
public $css = [
'css/site.css',
'css/bootstrap-reset.css',
'css/style.css',
'css/style-responsive.css',
];
public $js = [
'js/jquery.js',
];
public $depends = [
'yiiwebYiiAsset',
'yiibootstrapBootstrapAsset',
];
}

我的视图文件如下

<?php
use yiihelpersHtml;
use appassetsAppAsset;
AppAsset::register($this);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="ThemeBucket">
<link rel="shortcut icon" href="images/favicon.png">
<?php $this->registerCsrfMetaTags() ?>
<title><?= Html::encode($this->title) ?></title>
<?php $this->head() ?>
<!--Core CSS -->

</head>
<body class="login-body">

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

但是 css 根本没有加载,我看不到我在资产包中定义的任何 css

函数<?php $this->head() ?>只是添加一个占位符,其中必须放置所有头部元标记,样式,脚本。 调用<?php $this->endPage() ?>时,它会用注册的元标记、样式、脚本等替换占位符。

最新更新