• 我用 js 进行了控制,我一开始以为 bootstrap 自带这个功能呢。。。

    贴一下,给有需要的同学: $(function(){ $(".nav-collapse").find("li").each(function(){ var a = $(this).find("a:first")[0]; if ($(a).attr("href") === location.pathname){ $(this).addClass("active"); }else{ $(this).removeClass("active"); } }); })