li()
a(href="/dashboard")
span(style = "font-size:16px;" class = "pull-right hidden-xs showopacity glyphicon glyphicon-dashboard")
| Dashboard
li(class = "active")
a(href="#")
span(style = "font-size:16px;" class="pull-right hidden-xs showopacity glyphicon glyphicon-cloud-upload")
| Upload
li()
a(href = "/analyze")
span(style = "font-size:16px;" class="pull-right hidden-xs showopacity glyphicon glyphicon-stats")
| Analyze
li()
a(href = "/locate")
span(style = "font-size:16px;" class="pull-right hidden-xs showopacity glyphicon glyphicon-file")
| Locate
我想使用从node.js文件传递的参数显示所选导航项的活动类。我必须对此模板文件进行哪些更改?
答案 0 :(得分:0)
li(class = parameter ? "active": "")
a(href="/dashboard")
span(style = "font-size:16px;" class = "pull-right hidden-xs showopacity glyphicon glyphicon-dashboard")
| Dashboard
li(class = parameter ? "active": "")
a(href="#")
span(style = "font-size:16px;" class="pull-right hidden-xs showopacity glyphicon glyphicon-cloud-upload")
| Upload
li(class = parameter ? "active": "")
a(href = "/analyze")
span(style = "font-size:16px;" class="pull-right hidden-xs showopacity glyphicon glyphicon-stats")
| Analyze
li(class = parameter ? "active": "")
a(href = "/locate")
span(style = "font-size:16px;" class="pull-right hidden-xs showopacity glyphicon glyphicon-file")
| Locate
尝试这是否有效,三元运算符由pug支持