变量即使注释掉也会导致“未定义”错误

时间:2019-12-01 08:25:07

标签: javascript python pycharm flash-message

我在使用flask开发文章注释时遇到providers: [{ provide: LocationStrategy, useClass: HashLocationStrategy}] ,可能是由变量"Object of type 'Response' is not JSON serializable"引起的。

所以我评论了所有cips,但是,Pycharm仍然报告错误:

cips

我真的不明白。我没有注释所有cips变量吗?

这是我的html代码(如您所见,我注释所有cips)

"jinja2.exceptions.UndefinedError: 'cips' is undefined"

这是python(我也没有通过cips)

{% extends "base.html" %}

{% block title %}
    {{ article.title }}-Article
{% endblock %}

{% block content %}
<div class="articlePage">
        Title:{{ article.title }}<br/>
        PostTime:{{ article.postTime }}<br/>
        Email:{{ user.email[0]+"***"+user.email[user.email.index('@'):] }}<br/>
        Abstract:{{ article.abstract }}<br/>
        Highlight Part:{{ article.highlight_part }}<br/>
        Download Link:<a href="../{{ article.dl_link }}">download</a>
        <button><a href="../upvote/{{ article.id }}">up:{{ article.upvoteNum }}</a></button>
        <button><a href="../downvote/{{ article.id }}">down:{{ article.downvoteNum }}</a></button>
 </div>
<div class="post comment" >
    <form action="/{{ article.id }}/comment" method="post"  id="form">
         Email:<input type="email" name="email" required><br/>
         Content:<br/> <textarea name="content" id="" cols="30" rows="10"></textarea><br/>
    </form>
    <input type="text" id="code" disabled>
    <input type="text" id="input">
    <button onclick="validate()">submit</button>
    <script>
        // var cips=[];
    </script>
</div>
 <div class="comment" >
 <h1>COMMENTS</h1>
     <div id="div"></div>
    {% for i in range(0,comments |length) %}
        {% set comment=comments[i] %}
<!--        {% set cip=cips[i] |tojson %}-->
<!--        {% set commentState=cips[i].vote_state%}-->
        <p>{{ loop.index }}. Email:{{ comment.email }}</p>
        <p>PostTime:{{ comment.postTime }}</p>
        <p>Content:{{ comment.content }}</p>

        <div id="vote_div">

        </div>
        {% set up_btn_id='up_btn'~ i|string %}
        {% set down_btn_id='down_btn'~ i|string %}
     <script>
         // cips.push('{{cips[i]}}');
         //     commentState="{{ cips[i].vote_state}}";
         //     console.log(commentState);
         //     console.log('{{up_btn_id}}')
        </script>
<!--        {% if cip.vote_state ==0 %}-->
<!--            <button id='{{up_btn_id}}' onclick="upVote(this)">up:{{ comment.upvoteNum }}</button>-->
<!--&lt;!&ndash;        <button><a href="../cupvote/{{ comment.id }}">up:{{ comment.upvoteNum }}</a></button>&ndash;&gt;-->
<!--            <button id="{{down_btn_id}}" onclick="downVote(this)">down:{{ comment.downvoteNum }}</button>-->
<!--&lt;!&ndash;        <button><a href="../cdownvote/{{ comment.id }}">down:{{ comment.downvoteNum }}</a></button>&ndash;&gt;-->
<!--        {% elif cip.vote_state ==1 %}-->
<!--            <button id='{{up_btn_id}}' onclick="upVote(this)" style="color: green">up:{{ comment.upvoteNum }}</button>-->
<!--            <button id="{{down_btn_id}}" onclick="downVote(this)">down:{{ comment.downvoteNum }}</button>-->
<!--        {% else %}-->
<!--            <button id='{{up_btn_id}}' onclick="upVote(this)">up:{{ comment.upvoteNum }}</button>-->
<!--            <button id="{{down_btn_id}}" onclick="downVote(this)" style="color: red">down:{{ comment.downvoteNum }}</button>-->
<!--        {% endif %}-->


        {% if flag==1 %}
            <form action="../cdelete/{{ comment.id }}" method="post">
                Password:<input type="password" name="psw">
                <input type="submit" value="delete">
            </form>
        {% endif %}
    {% endfor %}

 </div>
{% endblock %}

0 个答案:

没有答案