Ionic - svg没有出现 [英] Ionic - svg does not appear

查看:587
本文介绍了Ionic - svg没有出现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了离子2 sidemenu的应用程序构建,但svg出现在Chrome中,但生成文件android-debug.apk后,svg不会出现在Android中:

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:

按照我使用的命令:

npm install -g ion cordova
离子启动myApp --v2 sidemenu
离子平台添加android
离子生成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?

推荐答案

也许是因为你使用了错误的路径,记得你在构建应用程序时,你有这个:

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

因此路径必须为./ assets / img / myapp.svg intread ../../ assets / img / myapp.svg,因为在已编译的应用程序中,您位于根目录中,就好像你正在index.html文件中加载evething,它也适用于浏览器

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

这篇关于Ionic - svg没有出现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆