<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="./iconfont/iconfont.css"> </head>
<body> <!-- <svg class="icon svg-icon" aria-hidden="true">
<use xlink:href="#icon1"></use>
</svg> -->
<script src="./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-LMLPHP

希望对你们有帮助!

05-28 23:12