Yii2框架的Menu导航生成器如何加入class呢?其实这个你跟进到源码看一下或者查下手册应该是能看到相关参数的,这里就直接丢出个示例代码吧:

如果要给li标签加class:

['label'=>'Home', 'url'=>['site/index'],'options'=>['class'=>'list-group-item']]

如果要给链接加class:

[
'label'=>'Home',
'url'=>['site/index'],
'options'=> ['class'=>'list-group-item'],
'linkOptions'=>['class'=>'item-a-class'],
]

参考链接:
https://stackoverflow.com/questions/25832160/yii2-how-can-i-add-a-class-to-label-of-a-menu-items#answer-25832550

Related Posts: Yii2如何给菜单导航加入class :

avatar