Javascript 使用下划线.js的模板呈现在IE8中不起作用
我使用的是Javascript 使用下划线.js的模板呈现在IE8中不起作用,javascript,jquery,templates,backbone.js,underscore.js,Javascript,Jquery,Templates,Backbone.js,Underscore.js,我使用的是Backbone.js和subline.js 它在包括IE9在内的所有其他浏览器中都可以正常工作,但是 我在IE8中遇到此错误 SCRIPT1010: Expected identifier underscore.js, line 1156 character 7 下面是我得到错误的代码 模板 <script type="text/template" id="maps-template"> <% _.each(data, function(d) { %&g
Backbone.js
和subline.js
它在包括IE9在内的所有其他浏览器中都可以正常工作,但是
我在IE8中遇到此错误
SCRIPT1010: Expected identifier
underscore.js, line 1156 character 7
下面是我得到错误的代码
模板
<script type="text/template" id="maps-template">
<% _.each(data, function(d) { %>
<map id="<%= d.for %>" name="<%= d.for %>">
<% _.each(d.area, function(d) { %>
<area shape="<%= d.shape %>" alt="<%= d.alt %>" title="<%= d.title %>" coords="<%= d.coords %>" href="<%= d.href %>" target="_blank" />
<% }); %>
</map>
<% }); %>
</script>
其中,pc.products.maps
是一组对象,如下所示
pc.products.maps = [
{
for: "dept_a",
area: [
{
coords: '426,136,618,173',
shape: 'rect',
href: 'example.com',
title: '',
alt: ''
},
{
coords: '427,156,718,173',
shape: 'rect',
href: 'example.com',
title: '',
alt: ''
},
{
coords: '428,186,818,173',
shape: 'rect',
href: 'example.com',
title: '',
alt: ''
}
]
},
{
for: 'dept_b',
area: [
.....
]
}
];
请帮我知道我哪里做错了。我只是在猜测,也许
for
是一个保留字?尝试将它放在对象数组中的双引号中,如“for”:“dept_b”,或者只更改该属性名称。这样,模板的编译版本将在。可能需要为属性重命名,或使用变量
选项将模板
。
pc.products.maps = [
{
for: "dept_a",
area: [
{
coords: '426,136,618,173',
shape: 'rect',
href: 'example.com',
title: '',
alt: ''
},
{
coords: '427,156,718,173',
shape: 'rect',
href: 'example.com',
title: '',
alt: ''
},
{
coords: '428,186,818,173',
shape: 'rect',
href: 'example.com',
title: '',
alt: ''
}
]
},
{
for: 'dept_b',
area: [
.....
]
}
];