首页 > 解决方案 > 如何在本地工作时在 HTML 文件中显示 SVG Sprite 图标?

问题描述

我正在使用 SVG 图标(来自 IcoMoon),问题是我在本地工作时看不到图标,但是当我在线上传页面时它工作正常。

<!doctype html>
<html>
<head>
    <title>SVG Icons</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <link href="css/style.css" rel="stylesheet" type="text/css">
</head>
<body>
    <svg class="ico ico-menu"><use xlink:href="icons/symbol-defs.svg#ico-menu"></use></svg></td>
    <script defer src="icons/svgxuse.min.js"></script>
</body>
</html>

我没有使用任何本地服务器。它是一个纯 HTML 文件。我想知道如何解决这个问题?

谢谢你

标签: htmlcsssvgiconssvg-sprite

解决方案


推荐阅读