template

模板不渲染

下面的 template 里有一行表格,但页面不会显示它。

项目数量
真实行2

克隆后才显示

const tpl = document.querySelector("#row-template");
const row = tpl.content.cloneNode(true);
document.querySelector("tbody").append(row);

模板内容保存在 template.content 的 DocumentFragment 中。