下面的 template 里有一行表格,但页面不会显示它。
const tpl = document.querySelector("#row-template"); const row = tpl.content.cloneNode(true); document.querySelector("tbody").append(row);
模板内容保存在 template.content 的 DocumentFragment 中。
template.content