我有一个数组:
videos = [{
"id":1,
"title": "Как построить открытую террасу к дому своими руками",
"src": "http://videohost.me/hDX4hWWV5Ok.mp4",
},{
"id": 2,
"title": "How To Learn Anything 10x Faster",
"description": "Interested in learning more about Charisma University? You’re going to spend thousands and thousands hours learning over the course of your life. What’s crazy is that despite the fact that we have all those hours sitting in the classroom, learning musical instruments, martial arts, business, language, whatever - no one teaches us how to optimize that learning experience.",
"src": "http://videohost.me/YLwFbwPbq.mp4",
}]
我尝试在网页中打印所有标题从字典:
{% for video in videos %}
<h2>{{ video.title}} </h2>
<h2>{{ video.id}} </h2>
<p></p>
<video src="{{ video.src }}" />
{% endfor %}
但是它只显示第一个标题。原因是什么?我该如何解决我的问题?
Just Modify:
<video src="{{ video.src }}" />
<video src="{{ video.src }}"></video>
这是浏览器的问题。
在进行上述修改之前,如果您尝试在浏览器中执行view page source
,您会发现:
<h2>Как построить открытую террасу к дому своими руками </h2>
<h2>1 </h2>
<p></p>
<video src="http://videohost.me/hDX4hWWV5Ok.mp4" />
<h2>How To Learn Anything 10x Faster </h2>
<h2>2 </h2>
<p></p>
<video src="http://videohost.me/YLwFbwPbq.mp4" />
因此,jinja没有问题,这是浏览器的问题。