<div class="navbg"> <ul class="menu"> <li> <a href="/" {if condition="request()->action() eq 'index' " }class='active'{/if} >网站首页</a> </li> {volist name="nav" id="v_nav"} <li> <a {if condition="request()->action() eq $v_nav.ename" }class='active'{/if} href="/index/{$v_nav.type|navtype}/{$v_nav.ename}">{$v_nav.name}</a> </li> {/volist} <div class="clear"></div> </ul> </div>
原理:通过获取控制器和方法名做判断