我在使用 SVG 和谷歌字体“Monoton”时出错

问题描述

伙计们, 当我在浏览器中打开 svg 文件时,它给了我一个“第 4 行第 76 列的错误:EntityRef:期望 ';' ” 这是 svg 代码

<svg xmlns="http://www.w3.org/2000/svg" width="96.75" height="33" viewBox="0 0 387 132">
  <defs>
    <style>
      @import url('https://fonts.googleapis.com/css2family=Monoton&display=swap');
      .cls-1 {
        font-size: 150px;
        fill: #888;
        font-family: Monoton;
      }
    </style>
  </defs>
  <text id="DAG" class="cls-1" x="-7.001" y="126.575">DAG</text>
</svg>

解决方法

删除:&display=swap(第 4 行第 76 列)

<svg xmlns="http://www.w3.org/2000/svg" width="96.75" height="33" viewBox="0 0 387 132">
  <defs>
    <style>
      @import url('https://fonts.googleapis.com/css2family=Monoton');
      .cls-1 {
        font-size: 150px;
        fill: #888;
        font-family: Monoton;
      }
    </style>
  </defs>
  <text id="DAG" class="cls-1" x="-7.001" y="126.575">DAG</text>
</svg>