我想在不同页面中突出显示导航栏的状态。 当我通常将导航栏放在base.html中并添加块内容时,它可以正常工作。
{
"id":"57e4d12e53a5a",
"body":"asdas",
"published":"Fri,
23 Sep 2016 06:52:30 +0000",
"type":"chat-message",
"actor":
{
"displayName":"beau",
"objectType":"person",
"image":
{
"url":"http://www.gravatar.com/avatar/205e460b479e2e5b48aec07710c08d50?s=80&d=mm&r=g",
"width":48,"height":48
}
}
}
{
"id":"57e4d51165d97",
"body":"jackiechanSADAS",
"published":"Fri, 23 Sep 2016 07:09:05 +0000",
"type":"chat-message",
"actor":
{
"displayName":"beau",
"objectType":"person",
"image":
{
"url":"http://www.gravatar.com/avatar/205e460b479e2e5b48aec07710c08d50?s=80&d=mm&r=g",
"width":48,
"height":48
}
}
}
{
"id":"asas",
"body":"peterting",
"published":"Fri, 23 Sep 2016 07:09:05 +0000",
"type":"chat-message",
"actor":
{
"displayName":"beau",
"objectType":"person",
"image":
{
"url":"http://www.gravatar.com/avatar/205e460b479e2e5b48aec07710c08d50?s=80&d=mm&r=g",
"width":48,
"height":48
}
}
}
在live_now.html中,我添加了class =“active”,它可以正常工作
<!DOCTYPE html>
<html lang=en>
<head>
<title>Dashboard</title>
{% include 'snippets/css.html' %}
</head>
<body>
<!-- Sidebar Holder -->
<nav id="sidebar">
<ul class="list-unstyled components">
<li{% block nav_live %}{% endblock %}>
<a href="{% url 'live_now' %}"><i class="fa fa-users" aria-hidden="true"></i>Live Now</a>
</li>
<li{% block nav_out %}{% endblock %}>
<a href="{% url 'outcome' %}"><i class="fa fa-crosshairs" aria-hidden="true"></i>Outcome Score</a>
</li>
<li {% block nav_customer %}{% endblock %}>
<a href="{% url 'customer_search' %}"><i class="fa fa-search" aria-hidden="true"></i>Customer search</a>
</li>
<li {% block nav_journey %}{% endblock %}>
<a href="#homeSubmenu" data-toggle="collapse" aria-expanded="false"><i class="fa fa-map-o" aria-hidden="true"></i> Journey Shaping</a>
<ul class="collapse list-unstyled" id="homeSubmenu">
<li><a href="{% url 'persona' %}">-Persona</a></li>
<li><a href="#">-Outcomes</a></li>
<li><a href="#">-Action Maps</a></li>
<li><a href="#">-Auto Responses</a></li>
</ul>
</li>
<li {% block nav_analytics %}{% endblock %}>
<a href="#analyticsmenu" data-toggle="collapse" aria-expanded="false"><i class="fa fa-bar-chart" aria-hidden="true"></i>Analytics</a>
<ul class="collapse list-unstyled" id="analyticsmenu">
<li><a href="#">-Visitor Activity</a></li>
<li><a href="#">-Visit History</a></li>
<li><a href="#">-Action Map Performance</a></li>
<li><a href="#">-Interactions</a></li>
</ul>
</li>
<li{% block nav_settings %}{% endblock %}>
<a href="#settingsmenu" data-toggle="collapse" aria-expanded="false"><i class="material-icons md-18" >tune</i>Settings</a>
<ul class="collapse list-unstyled" id="settingsmenu">
<li><a href="{% url 'set_phone' %}">-Phone Number</a></li>
<li><a href="{% url 'track_code' %}">-Tracking Code</a></li>
<li><a href="#">-Action Map Performance</a></li>
<li><a href="#">-Interactions</a></li>
</ul>
</li>
<li{% block nav_people %}{% endblock %}>
<a href="#peoplemenu" data-toggle="collapse" aria-expanded="false"><i class="material-icons">people</i>People</a>
<ul class="collapse list-unstyled" id="peoplemenu">
<li><a href="{% url 'teams' %}">-Team Home</a></li>
<li><a href="#">-Visit History</a></li>
<li><a href="#">-Action Map Performance</a></li>
<li><a href="#">-Interactions</a></li>
</ul>
</li>
</ul>
</nav>
{% block content %}{% endblock content %}
</div>
{% include 'snippets/js.html' %}
</body>
</html>
但是当我尝试在nav.html中将nav-bar包含为片段时,模板中不会呈现class =“active”
{% extends "base.html" %}
{% block nav_live %}
class="active"
{% endblock %}
{% block content %}
{% load static %}