加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

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

发布时间:2020-12-13 18:26:29 所属栏目:PHP教程 来源:网络整理
导读:好吧,我在AppAsset中声明了我所有的CSS和 JavaScript内容,但我不能让它在前端视图中显示css和js链接.这是我的文件: 应用程序/资产/ AppAsset.php: ?phpnamespace appassets;use yiiwebAssetBundle;class AppAsset extends AssetBundle { public $basePa
好吧,我在AppAsset中声明了我所有的CSS和 JavaScript内容,但我不能让它在前端视图中显示css和js链接.这是我的文件:

应用程序/资产/ AppAsset.php:

<?php

namespace appassets;

use yiiwebAssetBundle;
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 = [
        'yiiwebYiiAsset','yiibootstrapBootstrapAsset',];
}

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

<?php

use appassetsAppAsset;

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>

希望它对某人有帮助

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读