Javascript 未捕获语法错误-意外标识符下划线.min.js第24行

Javascript 未捕获语法错误-意外标识符下划线.min.js第24行,javascript,model-view-controller,backbone.js,backbone-views,Javascript,Model View Controller,Backbone.js,Backbone Views,我得到了未捕获的语法错误 意外标识符-下划线.min.js 24 在模板中添加此复选框代码后出现错误: template: _.template('<h3>'+'<input type=checkbox'+'<% if(status === "complete") print("checked") %> />' + '<% = name %></h3>'), template:u.template(“”+“”+“”), 我猜错误在模

我得到了未捕获的语法错误

意外标识符-下划线.min.js 24

在模板中添加此复选框代码后出现错误:

template: _.template('<h3>'+'<input type=checkbox'+'<% if(status === "complete") print("checked") %> />' + '<% = name %></h3>'),
template:u.template(“”+“”+“”),
我猜错误在模板的复选框代码中,我不知道那是什么

下面是我的代码:

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
<meta name="description" content="">
</head>
<body>

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.cdnjs.com/ajax/libs/underscore.js/1.1.4/underscore-min.js"></script>
<script type="text/javascript" src="http://ajax.cdnjs.com/ajax/libs/backbone.js/0.3.3/backbone-min.js"></script>

</body>

<script>

var Friend = Backbone.Model.extend({});

var friend = new Friend ({ name:'phani'});

var FriendView = Backbone.View.extend({
    el:'body',
    tagName:'article',
    id:'my-friend',
    className:'hello-friend',

    //template
    template: _.template('<h3>'+'<input type=checkbox'+'<% if(status === "complete") print("checked") %> />' + '<% = name %></h3>'),

    //event
    events:{
    "click h3":"alertStatus"
    },

    alertStatus: function(e){
        alert("Hey you clicked the h3!");
        },

    render:function(){
    var attributes = this.model.toJSON();
    $(this.el).html(this.template(attributes));
    }

});

var friendView = new FriendView({model:friend});
friendView.render();
console.log(friendView.el);

</script>

var-Friend=Backbone.Model.extend({});
var friend=新朋友({name:'phani'});
var FriendView=Backbone.View.extend({
el:“身体”,
标记名:'article',
id:“我的朋友”,
类名:'hello-friend',
//模板
模板:u.模板(“”+“”+“”),
//事件
活动:{
单击h3:“警报状态”
},
警报状态:功能(e){
警报(“嘿,你点击了h3!”);
},
render:function(){
var attributes=this.model.toJSON();
$(this.el).html(this.template(attributes));
}
});
var-friendView=new-friendView({model:friend});
render();
console.log(friendView.el);

我不确定这是错误的根源,但在这行中

template: _.template('<h3>'+'<input type=checkbox'+'<% if(status === "complete") print("checked") %> />' + '<% = name %></h3>'),
template:u.template(“”+“”+“”),
您可能应该在“checked”之前有一个空格,否则您将得到类似的结果

<input type=checkboxchecked />


顺便说一下,您应该在
复选框
周围加上双引号。

哪里是
状态
定义的`?我建议在模板中添加一个
debugger
语句:是的,这解决了我的复选框一开始并没有被选中的问题。但是这个错误实际上是因为没有像这样包装print函数{%>..>%}。谢谢