I'm writing a Vue component that dynamically renders an SVG. Usually <style> tags are not allowed in Vue templates, but is there any way to allow it in this particular situation?
The following will either throw an error, or generate an svg without the style tag, depending on how your project is setup (Code Sandbox):
<template>
<svg :width="svgWidth" :height="svgHeight">
<style>rect{fill:red}</style>
<rect :height="rectHeight" :width="rectWidth" />
</svg>
</template>
One obvious workaround is to use inline styling for all elements, but for convenience I wonder if it possible to tell Vue to leave the style tag inside the svg tag alone?
(I'm generating both style and SVG elements dynamically, so it would make for a more readable code and a much smaller rendered SVG element.)
I'd like to make the SVG self-contained, i.e. keeping the style tag inside the rendered image.