2017-06-21 68 views
0
<?xml version="1.0" encoding="UTF-8" standalone="no"?> 
<svg width="20px" height="20px" viewBox="0 0 20 20" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> 
    <defs></defs> 
    <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"> 
     <g id="icons" transform="translate(-368.000000, -426.000000)"> 
      <g id="attention-blue" transform="translate(368.000000, 426.000000)"> 
       <circle id="Oval-13" fill="#34C6D9" cx="10" cy="10" r="10"></circle> 
       <path d="M10,10.8 L10,5.6" id="Line" stroke="#FFFFFF" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"></path> 
       <path d="M10,14.8 L10,14.8" id="Line2" stroke="#FFFFFF" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"></path> 
      </g> 
     </g> 
    </g> 
</svg> 

我有兩個「路徑」標記的SVG圖標。在用imagemin.svgo imagemin構建之後,刪除這個「路徑」中的一個,我的圖標看起來非常糟糕。我怎樣才能解決這個問題?Imagemin svgo刪除路徑

gimagemin.svgo({ 
    plugins: [ 
     {minifyStyles: false}, 
     { removeViewBox: false }, 
     { removeUselessStrokeAndFill: false }, 
     { cleanupIDs: false } 
     ] 
    }) 

這是我的選擇。

回答

0

實際上,SVGO並沒有刪除第二個路徑,它將它合併到第一個路徑中(它通過默認啓用的「mergePath」插件完成)。 但是,由於第二條路徑長度爲零,因此SVGO刪除了「lineto」(「L10,14.8」)命令(「convertPathData」插件是這樣做的),因此它減少爲無用的「moveto」(M10 14.8)命令。

我建議不要以這種風格繪製圖像。您可以使用另一個<circle>,或在arc curves的路徑中繪製一個圓圈。

當然,您可以禁用「convertPathData」插件爲這個特定的圖像,但我不建議它作爲一個通用的解決方案,因爲它是基本的優化插件之一。