<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta content="width=device-width, initial-scale=1.0"> <title>Document</title> <link href="http://www.likecs.com/iconfont/iconfont.css"> </head> <body> <!-- <svg aria-hidden="true"> <use xlink:href="#icon1"></use> </svg> --> <script src="http://www.likecs.com/iconfont/iconfont.js"></script> <script> let svgns = "http://www.w3.org/2000/svg"; let xlinkns = "http://www.w3.org/1999/xlink"; let icon = document.createElementNS(svgns, "svg"); icon.setAttribute("aria-hidden", true); let use = document.createElementNS(svgns, "use"); use.setAttributeNS(xlinkns, "href", "#icon1"); icon.appendChild(use); document.body.appendChild(icon) </script> </body> </html>
js动态创建svg与use 使用iconfont symbol
内容版权声明:除非注明,否则皆为本站原创文章。