Yii2 AppAsset在布局中不生成css / js链接

前端之家收集整理的这篇文章主要介绍了Yii2 AppAsset在布局中不生成css / js链接前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
好吧,我在AppAsset中声明了我所有的CSS和 JavaScript内容,但我不能让它在前端视图中显示css和js链接.这是我的文件

应用程序/资产/ AppAsset.PHP

<?PHP

namespace app\assets;

use yii\web\AssetBundle;
class AppAsset extends AssetBundle {
    public $basePath = '@webroot';
    public $baseUrl = '@web';
    public $css = [
        'assets/css/bootstrap.min.css','assets/plugins/weather-icon/css/weather-icons.min.css',...
    ];
    public $js = [
    ];
    public $depends = [
        'yii\web\YiiAsset','yii\bootstrap\BootstrapAsset',];
}

这是我的布局(app / modules / admin / layouts / admin.PHP):

<?PHP

use app\assets\AppAsset;

AppAsset::register($this);
?>

<?PHP $this->beginPage() ?>
<!DOCTYPE html>
<html lang="en">
    <head>
        <?PHP $this->head() ?>
        <?= $this->render('partials/head') ?>
    </head>
<body class="tooltips">
    <?= $this->render('partials/colour_panel') ?>
        <div class="wrapper">
            <?= $this->render('partials/top_navbar') ?>
            <?= $this->render('partials/left_sidebar') ?>
            <?= $this->render('partials/right_sidebar') ?>
            <div class="page-content">
                <div class="container-fluid">
                    <?= $content ?>
                    <?= $this->render('partials/footer') ?>
                </div>
            </div>
        </div>
        <?= $this->render('partials/scripts') ?>
    </body>
</html>
<?PHP $this->endPage() ?>

提前致谢!

我有同样的问题.在我的情况下,布局没有<?PHP $this-> beginBody()?>和<?PHP $this-> endBody()?>里面的部分< body>< / body>标签.

它应该是这样的:

<body>
<?PHP $this->beginBody() ?>
   <!--content-->
<?PHP $this->endBody() ?>
</body>

希望它对某人有帮助

原文链接:https://www.f2er.com/php/135829.html

猜你在找的PHP相关文章