Tutorial: How to get a hardcoded SVG image that can be used inside the <script> tag #16222
Unanswered
BenJackGill
asked this question in
General - Components / Directives / etc
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
UPDATE:
Quasar SVG strings contain a mix of
path,style,transformandviewboxinformation. And they use various delimiters to seperate them. There can also be multiple paths for each svg.So I built this function to parse and build a hardcoded SVG from all of that information:
You can use it like this:
The above code will console log this string:
ORIGINAL POST:
I needed a hardcoded HTML img/svg tag to use with apexcharts inside the
<script>tag and I had a hard time figuring it out.But I got there eventually. So if anyone else needs a hardcoded SVG image from the Quasar icon sets this is how you can do it...
The first thing to know is that Quasar store SVG icons as a concatenation of theSVG path data and the viewBox data, using
|as a delimiter between those things. See here.So to get it working you need to import the icon, then split the string based on the
|delimiter. That will give you two parts. The first part is the SVGpathdata, and the second part is the SVGviewBoxdata.Then you build the SVG from that.
For example:
Hope that helps anyone else who needs a hardcoded SVG image string.
All reactions