JS获取带有<template>表内容的HTML '' innerHTML失败



在HTML文件中,我有以下内容:

<template id="notWorking">
<table class="table table-xs table-hover">
<thead>
<tr>
<th>Conteneur</th>
</tr>
</thead>
<tbody>
{{ each(options.dossier.conteneurs) }}
<tr>
<td>{{ @this.numConteneur }}</td>
</tr>
{{ /each }}
</tbody>
</table>
</template>

但当我调用console.log(document.getElementById("notWorking").innerHTML)时,我得到以下信息:


{{ each(options.dossier.conteneurs) }}
{{ /each }}
<table class="table table-xs table-hover">
<thead>
<tr>
<th>Conteneur</th>
</tr>
</thead>
<tbody><tr>
<td>{{ @this.numConteneur }}</td>
</tr></tbody>
</table>

元素似乎没有被正确解析。。。?我是不是做错了什么?

请参阅:https://codepen.io/nebrelbug/pen/OJJEvmW

<tbody>只能将<tr>作为子级。不允许使用文本内容。

最新更新