[英]underscore unexpected token <
Here's my code. 这是我的代码。
<script type="text/javascript" id="styles_section">
<select>
<%_.each(colorOption, function(color){ %>
<option><%= color.get("color_name") %></option>
<% }); %>
</select>
</script>
I can't seem to find what's wrong with my code. 我似乎找不到我的代码出了什么问题。
EDIT: 编辑:
Here's the json code as requested. 这是要求的json代码。
var myColors = [{ color_name: 'white', color_code: '#ffffff'},
{color_name: 'black', color_code: '#000000'}];
Here's the backbone part. 这是骨干部分。
var colorOption = new Backbone.Collection(myColors);
var colors = new SelectColorView({
model: colorOption,
});
Script tag is also used for micro templates. 脚本标签也用于微型模板。 For micro template, script tag type
should not be text/javascript
. 对于微型模板,脚本标记type
不应为text/javascript
。
For micro templates, script tag is as follows 对于微型模板,脚本标签如下
<script type="text/template"></script>
By setting the type to "text/template", it's not a script that the browser can understand, and so the browser will simply ignore it. 通过将类型设置为“文本/模板”,它不是浏览器可以理解的脚本,因此浏览器将直接忽略它。 This allows you to put anything in there, which can then be extracted later and used by a templating library to generate HTML snippets. 这样,您就可以在其中放置任何内容,然后可以随后将其提取出来,并由模板库用于生成HTML代码段。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.