, I clicked the work education experience, the page refreshed, at this time the activation of the project became a work education experience, how is this achieved?
Is the backstage passed to the foreground which Li was activated? Or is there another way to implement it?
Reply content:
, I clicked the work education experience, the page refreshed, at this time the activation of the project became a work education experience, how is this achieved?
Is the backstage passed to the foreground which Li was activated? Or is there another way to implement it?
Judging the current page based on URL incoming parameters $tab
<>
class="current"
>xxx
<>
class="current"
>xxx
First of all, thank you for inviting me to answer. Then your so-called activation, in fact, is to give li
a class="current"
property, as to how to judge, this is more simple.
Segmentfault this should be in the back-end judgment, this WordPress and other programs in the subject is written, the idea should be the same as you, each judge whether it is the current page, is the addition, not the addition.
But recently wrote the topic of static blog, found that they have such a train of thought. The program has a extends
and block
function that can define the parent template and the replication item, for example, I base.html
define the
你好我是首页
你好我是用户页
你好我是文章页
And then I wrote this in the user page.
{% extends 'base.html' %} {# 表示把base.html继承了过来 #}{% block user %} class="current"{% endblock %} {#表示给上面定义的一个可以复写项赋值#}
So eventually my user page will show this effect.
你好我是首页你好我是用户页你好我是文章页
This can also achieve the goal. Of course you can also choose to judge in the front, to each li
add a corresponding class
, the best and URL
the call name consistent, and then based on URL
the value of the direct assignment to the corresponding object is made.
In general, if you don't want to give
Add a separate logo, it can only be in the background/front-end a judge, if you add a separate logo can be a little faster, the back end/front end is not limited.