如何根据URL将活动标记设置为类?
在下面的示例中,'/'(Home)设置为活动状态.
.nav-collapse.collapse
ul.nav.top-2
li.active
a(href='/') Home
li
li
a(href='/about') About
li
li
a(href='/contact') Contact
li
Run Code Online (Sandbox Code Playgroud)
在页面中注入一些内容以将其标识为活动页面会更好吗?
Mic*_*Yin 10
这就是我所做的,如六氰化物的例子,
res.render('/path', {
path: req.path
});
Run Code Online (Sandbox Code Playgroud)
..并在layout.jade中:
.nav-collapse.collapse
ul.nav.top-2
li(class=path=='/'?'active':undefined)
a(href='/') Home
li(class=path=='/about'?'active':undefined)
a(href='/about') About
li(class=path=='/contact'?'active':undefined)
a(href='/contact') Contact
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2821 次 |
| 最近记录: |