美文网首页
Yii2 menu navbar nav小部件的使用示例

Yii2 menu navbar nav小部件的使用示例

作者: guanguans | 来源:发表于2018-01-31 14:37 被阅读377次
    • menu示例
    Menu::widget( [
        [
            'label' => $menu['name'],
            'url' => [$menu['route']],
            'items' => [
                    [
                         'label' => $menu['name'],
                         'url' => [$menu['route']]
                ],
                ....
            ]
        ],
        [
            'label' => $menu['name'],
            'url' => [$menu['route']],
            'items' => [
                    [
                         'label' => $menu['name'],
                         'url' => [$menu['route']]
                ]
            ]
        ],
        ..
    ] );
    
    • navbar&nav
    NavBar::begin([
            'brandLabel' => 'My Company',
            'brandUrl' => Yii::$app->homeUrl,
            'options' => [
                'class' => 'navbar-inverse navbar-fixed-top',
            ],
        ]);
    $menuItems = [
        ['label' => 'Home', 'url' => ['/site/index']],
        ['label' => 'About', 'url' => ['/site/about']],
        ['label' => 'Contact', 'url' => ['/site/contact']],
    ];
    echo Nav::widget([
    'items' => [
        [
            'label' => 'Home',
            'url' => ['site/index'],
            'linkOptions' => [],
        ],
        [
            'label' => 'Dropdown',
            'items' => [
                ['label' => 'Level 1 - Dropdown A', 'url' => '#'],
                    '<li class="divider"></li>',
                    '<li class="dropdown-header">Dropdown Header</li>',
                ['label' => 'Level 1 - Dropdown B', 'url' => '#'],
            ],
        ],
        [
            'label' => 'Login',
            'url' => ['site/login'],
            'visible' => Yii::$app->user->isGuest
        ],
    ],
    'options' => ['class' =>'nav-pills'], // set this to nav-tab to get tab-styled navigation
    ]);
    NavBar::end();
    

    相关文章

      网友评论

          本文标题:Yii2 menu navbar nav小部件的使用示例

          本文链接:https://www.haomeiwen.com/subject/dbokzxtx.html