HTML template 元素
默认情况下,<template> 标签内的图标不会被添加。 将 inTemplates 选项设置为 true 后,template 中的图标也会被替换。
可以在 MDN 的 HTML template 元素文档中了解更多。
在 template 元素中使用 createIcons 函数的示例
import { createIcons, Backpack } from '@ycloud-web/icons'; 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);