zoukankan      html  css  js  c++  java
  • yii2顶部导航使用

    yii2中使用顶部导航的具体方法:

    1.视图中调用两个类:

    use yiiootstrapNav;
    use yiiootstrapNavBar;

    2. <?php
                NavBar::begin([
                    'brandLabel' => 'My Company',
                    'brandUrl' => Yii::$app->homeUrl,
                    'options' => [
                        'class' => 'navbar-inverse navbar-fixed-top',
                    ],
                ]);
                $menuItems = [
                    ['label' => 'Home', 'url' => ['/site/index']],
                    ['label'=>'注册','url'=>['/manager/register']],
                    ['label'=>'关于我们','url'=>['/site/about']],
                ];
                if (Yii::$app->user->isGuest) {
                    $menuItems[] = ['label' => 'Login', 'url' => ['/site/login']];
                } else {
                    $menuItems[] = [
                        'label' => 'Logout (' . Yii::$app->user->identity->username . ')',
                        'url' => ['/site/logout'],
                        'linkOptions' => ['data-method' => 'post']
                    ];
                }
                
                echo Nav::widget([
                    'options' => ['class' => 'navbar-nav navbar-right'],
                    'items' => $menuItems,
                ]);
                NavBar::end();
            ?>

      

    效果如下图:

  • 相关阅读:
    使用iText 7读取PDF文件中的文本和图片
    登记或取消登记盈亏库存日记账行数量
    uni-app(未完)
    javaScript的基本优雅写法
    ModuleFederation-模块联邦
    typescript
    img标签src图片路径根目录问题
    开源工具分享
    软件缺陷的度量、分析和统计
    MIT6.824 2020 Lab2 A Raft Leader Election
  • 原文地址:https://www.cnblogs.com/xlz307/p/3858067.html
Copyright © 2011-2022 走看看