Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 48979

Dynamic import specific icon from ionicons?

$
0
0

I want to show user ionicons on the screen, after he chooses one I want to save it to backend(not the whole svg, only the name) afterwards I want to show this specific icon on some screens.

Since I use Ionic Vue i am importing specific icon and using it in ion icon component as
<ion-icon :icon='whatever'> </ion-icon>

and first i import it from ionicons

import { whatever } from 'ionicons/icons'

How can I make this import dynamic so i import only icon user chose?

I found some solutions online and this one only worked :

import * as icons from 'ionicons/icons';

and then I can do icons['whatever'] which will give me same result as above.
I can then change ‘whatever’ to variable and make this dynamic.

This is working however I am importing all the icons and I wanted to know if there is cleaner way to import only the icon user chose and not all of them and then taking just one.

3 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 48979

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>