How does WeChat Mini Programs display SVG?

1. Question:

The data returned by the

background is a link to the svg image, such as:" http://abc.com/a.svg". Now to render in Mini Program page, Mini Program has no SVG component.

2. Try to put the link directly in the src of the image component without displaying it.

3. Or how to convert the SVG code in Mini Program into the base64? available for the picture.
PC can use src= "data:image/svg+xml;base64," + the svg code that window.btoa (unescape (encodeURIComponent (wants to convert), but how to transfer it in Mini Program?

ask the god!


got it. It got complicated at first. It turns out that Mini Program api can be converted into base64. The code is as follows

  

just play svg with image src

Menu