Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ionic - svg does not appear

I made the application build of the ionic 2 sidemenu, however the svg appears in the Chrome but svg does not appear in Android after generate the file android-debug.apk:

enter image description here

Follow the commands I used:

npm install -g ionic cordova ionic start myApp --v2 sidemenu ionic platform add android ionic build android

/myApp/src/pages/page1/page1.html

<ion-header>
    <ion-navbar>
        <button ion-button menuToggle>
            <ion-icon name="menu"></ion-icon>
        </button>
        <ion-title>Page One</ion-title>
    </ion-navbar>
</ion-header>
<ion-content padding>
    <h3>Ionic Menu Starter</h3>
    <img src="../../assets/img/myapp.svg" alt="">
    <p>
        If you get lost, the
        <a href="http://ionicframework.com/docs/v2">docs</a> will show you the way.
    </p>
    <button ion-button secondary menuToggle>Toggle Menu</button>
</ion-content>

Could you help me solve this problem?

like image 236
rafaelcb21 Avatar asked Dec 12 '25 05:12

rafaelcb21


1 Answers

Maybe it is because you use the wrong path, remember when you build an app, you have this:

enter image description here

So the path is need to be "./assets/img/myapp.svg" intread "../../assets/img/myapp.svg" , because in a compiled app you are in the root , it's as if you are loading evething in the index.html file, and it's also works in the browser

like image 160
JoxieMedina Avatar answered Dec 13 '25 19:12

JoxieMedina



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!