Javascript 下划线模板添加额外的<;h2>;标签

Javascript 下划线模板添加额外的<;h2>;标签,javascript,backbone.js,underscore.js,Javascript,Backbone.js,Underscore.js,我有一个简单的模板: <script type="text/template" id="dashboard_tem"> <h2>Dashboard<h2> </script> 但是,this.$elhtml变成: <div> <h2>Dashboard</h2><h2></h2> </div> 仪表板 请注意末尾的额外。为什么会这样?我认为您希望

我有一个简单的模板:

  <script type="text/template" id="dashboard_tem">
    <h2>Dashboard<h2>
  </script>
但是,
this.$el
html变成:

<div>
    <h2>Dashboard</h2><h2></h2>
</div>

仪表板

请注意末尾的额外
。为什么会这样?

我认为您希望在将h2设置为变量tem之前关闭h2:

<script type="text/template" id="dashboard_tem">
  <h2>Dashboard<h2>
</script>

仪表板
改为

<script type="text/template" id="dashboard_tem">
  <h2>Dashboard</h2>
</script>

仪表板

仪表板
=>
仪表板
顺便说一句,您得到的结果是因为您无法将
放入
中,因此浏览器在打开第二个
之前关闭第一个
<script type="text/template" id="dashboard_tem">
  <h2>Dashboard</h2>
</script>