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

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();
上一篇:ThinkCMF-首页Nav部分菜单配置详解


下一篇:.NetCore Linux环境下安装InfluxDB以及配置设置