Utilizing an SVG sprite file in a Vue JS HTML template is successful with the following setup:
<svg class="icon">
<use xlink:href="~@/assets/images/icons.svg#edit"></use>
</svg>
The contents of the icons.svg
file typically resemble the structure below:
<svg style="display: none;">
<symbol id="edit" viewbox="0 0 15 15">
<g>...</g>
</symbol>
</svg>
However, attempting to utilize the same SVG fragment in a Vue CSS file as shown below leads to failure:
.edit-icon{
background:url('~@/assets/images/icons.svg#edit') no-repeat;
background-size: 15px 15px;
}
It seems that the browser can only locate the #edit
symbol within HTML. Is there a method to employ this same SVG sprite approach in a CSS background?