小编wpe*_*rak的帖子

无法使用 django 变量和 javascript 变量创建 if 条件

我是 javascript 中的变量类型表,我需要if在此变量和 django 数据库中的变量之间使用条件进行测试,但它不起作用。

这个例子 :

var test_date = "2017-06-23";
var locations = [
    {% for v in vs %}

        {% if v.date ==  test_date %}

            ['okok',{{ v.latitude }},{{ v.longitude}}],

        {% endif %}

    {% endfor%}
        ]
Run Code Online (Sandbox Code Playgroud)

第一个例子不起作用,我不知道为什么。

另一个例子:

var test_date = "2017-06-23";
var locations = [
    {% for v in vs %}

        {% if v.date ==  "2017-06-23" %}

            ['okok',{{ v.latitude }},{{ v.longitude}}],

        {% endif %}

    {% endfor%}
        ]
Run Code Online (Sandbox Code Playgroud)

当我将变量的值放入测试中时,它正在工作

javascript python django django-templates

0
推荐指数
1
解决办法
2277
查看次数

标签 统计

django ×1

django-templates ×1

javascript ×1

python ×1