Skip to content

内容模板元素

🌐 Content Template element

默认情况下,<template> 标签内的图标不会被添加。 通过将 inTemplates 选项设置为 true,模板内的图标也会被替换。

🌐 By default icons inside <template> tags are not added. By setting the inTemplates option to true, icons inside templates will also be replaced.

更多关于 MDN 上的内容模板元素 的信息。

🌐 More about Content Template element on MDN.

使用 createIcons 函数与 template 元素的示例

🌐 Example using createIcons function with template element

import { createIcons, Backpack } from 'lucide/dist/cjs/lucide';
import "./styles.css";

createIcons({
  icons: {
    Backpack,
  },
  inTemplates: true
});

const container = document.getElementById("container");
const template = document.getElementById("template");

const firstClone = document.importNode(template.content, true);
container.appendChild(firstClone);

const secondClone = document.importNode(template.content, true);
container.appendChild(secondClone);