IE8:预期的标识符,字符串或数字

时间:2014-02-06 10:44:07

标签: javascript internet-explorer internet-explorer-8

我在以下代码的IE8 Expected identifier, string or number中收到错误referring to line 17 character 21

define(
    [
        "underscore"
    ,   "Backbone"
    ,   "text!assetListingTemplate"
    ]
,   function(_, Backbone, template) {
        "use strict";

        var tmpl = _.template(template);
        var AssetListing = Backbone.View.extend({
            tagName: "li"

        ,   attributes: function() {
                return {
                    id: this.model.cid
                ,   class: this.model.get("type")
                };
            }

        ,   render: function() {
                this.el.innerHTML = tmpl(this.model.attributes);
                return this.el;
            }
        });

        return AssetListing;
    }
);

这是:

,   class: this.model.get("type")

此错误通常是由于Object中的尾随昏迷或IE无法正常处理的类似次要格式问题引起的。也许我一直在盯着代码太长时间但我在这里看不到任何这样的问题,我甚至JSLinted它并没有找到任何问题,除了不同意我的风格。

错误不是this.model,因为如果我为常规字符串替换它的所有实例,它仍然会出现。

任何鹰眼都可以看到这里出了什么问题吗?

1 个答案:

答案 0 :(得分:4)

它不喜欢class,因为类是ECMAScript2中定义的future reserved word

class放在引号"class"

attributes: function() {
                return {
                    id: this.model.cid
                ,   "class": this.model.get("type")
                };
            }
相关问题