Open mitskovets opened 5 years ago
1) Install per the instructions:
tns plugin add nativescript-svg
2) Add the following to main.js:
import Vue from 'nativescript-vue'
Vue.registerElement('SVGImage', () => require('nativescript-svg').SVGImage)
3) Use as any other Component:
<SVGImage src="~/assets/images/nativescript.svg" height="100" />
can you commit a PR with that in the readme file, please?
Sorry for my english ) I do exactly that, but the SVG is not displayed, it is on the page (width & height) , it is empty, no color, no fill, why? Used different files SVG, no difference.
Sorry, should have mentioned that I am using iOS. I am having the same problem testing with Android (image is empty).
I got the same problem. Not working on Android.
Same problem here :(
Is there any workaround for that?
I made it work with this fork: https://github.com/exeleon/nativescript-svg I only tested it on Android Pie (for now) with Nativescript-Vue and it's working fine!
@sebj54 I've tried this on Oreo and Pie and can't get it to show up. Did you do anything different than described above to have an image display?
tns plugin add @exeleon/nativescript-svg
Vue.registerElement('SVGImage', () => require('@exeleon/nativescript-svg').SVGImage);
<SVGImage src="~/assets/images/nativescript.svg" height="100" />
EDIT: nevermind, got it working: case-sensitive pathing. Filename started with a capital letter but the path did not.
EDIT 2: It works in Oreo and Pie for me, but that's all I've tested so far.
I had the same problem with SVG not displaying. This steps helped me:
tns plugin remove nativescript-svg
tns plugin add @teammaestro/nativescript-svg
~/assets/images
folder, like ~/assets/images/icons/*.svg
(I think it's the step that resolved the issue, not the fork installation)Edit: I did my research and turns out there is a bug on Android and the second step fixes it
Any chance whatever makes the other 2 versions mentioned above work on android gets ported to here?
Hi Guys, any chance someone know if there is any existing issue i'm not a ware of in case src is a url ?
for e.g:
<SVGImage src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/39255/face.svg"/>
if i use the local assets, it works fine. only the link url doesn't work
Any advise will be much appreciated.
I'm currently using the teammaestro 1.0.1 with nativescript vue 6.2
Thank you!
I had the same problem with SVG not displaying. This steps helped me:
- Removing the nativescript-svg
tns plugin remove nativescript-svg
- Installing its fork by @teammaestro
tns plugin add @teammaestro/nativescript-svg
- ~(!) Placing all of the svg files under the
~/assets/images
folder, like~/assets/images/icons/*.svg
(I think it's the step that resolved the issue, not the fork installation)~- Steps 2 and 3 from @CAJazzer 's comment
Edit: I did my research and turns out there is a bug on Android and the second step fixes it
I am using Nativescript 7 and tried using this but got this error
JS: TypeError: Class constructor View cannot be invoked without 'new'
@edsel77 You should use this fork for NativeScript 7: https://github.com/SergeyMell/nativescript-plugins/tree/main/packages/nativescript-svg
How to use this plugin for the nativescript-vue?