完成个人中心—导航标签

Posted 008马佳槟

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了完成个人中心—导航标签相关的知识,希望对你有一定的参考价值。

@app.route(/usercenter/<user_id>/<tag>)

def usercenter(user_id,tag):
    user = User.query.filter(User.id == user_id).first()
    context = {
        username_id: user.id,
        username: user.username,
        wenda: user.wenda,
        comments: user.comment

    }
    if tag ==1:
        return render_template(userquestion.html,**context)
    elif tag ==2:
        return  render_template(usercomment.html,**context)
    else:
        return  render_template(usercenter.html,**context)
    <div class="col-md-4 column">
            <div class="panel panel-default">
                <div class="panel-heading">

                    <h3 class="panel-title">标题:{{quest.title }}</h3>
                    <a href="{{ url_for(‘usercenter‘,user_id=quest.author_id,tag=1)}}">作者:{{ quest.author.username}}</a>
                </div>
                <div class="panel-body">
                     <a href="#">内容:{{quest.detail }}</a><br>
                </div>
                <div class="panel-footer">
                <span class="badge" style="margin-left: 60%">{{quest.creat_time }}发布时间</span>
                </div>
            </div>
        </div>
        <div class="col-md-4 column">
        </div>
    </div>
</div>
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title">
                        <a href="{{ url_for(‘detail‘,question_id=foo.id)}}">标题:{{foo.title }}</a><br>
                    </h3>
                    <a href="{{ url_for(‘usercenter‘,user_id=foo.id,tag=1)}}">{{ foo.author.username }}</a>
                </div>

                <div class="panel-body">
                  <a href="#">内容:{{foo.detail }}</a><br>
                </div>
                <div class="panel-footer">
                     <span class="badge" style="margin-left: 60%">{{foo.creat_time }}发布时间</span>
                </div>
            </div>
          {% endfor %}
        </div>
        <div class="col-md-4 column">
        </div>
    </div>
</div>
<ul class="nav_ul">
    <li role="presentation"><a href="{{ url_for(‘usercenter‘,user_id = username_id,tag = 1) }}">question</a> </li>
    <li role="presentation"><a href="{{ url_for(‘usercenter‘,user_id = username_id,tag = 2) }}">comments</a> </li>
    <li role="presentation"><a href="{{ url_for(‘usercenter‘,user_id = username_id,tag = 3) }}">information</a> </li>

</ul>
{% block user %}}{% endblock %}
{% endblock %}
</html>

 

以上是关于完成个人中心—导航标签的主要内容,如果未能解决你的问题,请参考以下文章

完成个人中心—导航标签

完成个人中心—导航标签

完成个人中心—导航标签

完成个人中心—导航标签

完成个人中心—导航标签

完成个人中心—导航标签