简体   繁体   English

ionic应用程序无法在android中呈现svg文件,但适用于ios

[英]ionic app does not render svg files in android but does for ios

I'm really new to hybrid web apps and I'm currently trying to build an app that will allow me to display a number of svg files as ion-list items from an ng-repeat. 我真的是混合Web应用程序的新手,并且我目前正在尝试构建一个应用程序,该应用程序将允许我从ng-repeat中显示许多svg文件作为离子列表项。 Now I initially had an issue displaying these in my emulator until instead of using an image tag I used a div with an ng-include and a link to the url of the image. 现在,我最初遇到了在模拟器中显示这些内容的问题,直到使用div以及ng-include和指向图像网址的链接,而不是使用image标签。 This works fine in the Ripple emulator and it also works fine when I'm serving the app via phonegap to an ios device, but for android it doesn't render the images. 这在Ripple模拟器中可以正常工作,当我通过phonegap向ios设备提供应用程序时也可以正常工作,但对于android,它无法渲染图像。

Does anyone have any idea why? 有谁知道为什么吗?

Thanks to Paul LeBeau for his question, it pointed me in the right direction to solve this issue. 感谢Paul LeBeau的问题,它为我指出了解决这个问题的正确方向。

I added the type="image/svg+xml" attribute to a html object element to resolve this issue. 我将type =“ image / svg + xml”属性添加到html对象元素以解决此问题。

SVG background images referenced in css also didn't show up under ios in my case. 在我的情况下,css中引用的SVG背景图像也未在ios下显示。 But they will render correctly if set as a data attribute inline: 但是,如果将它们设置为内联的data属性,它们将正确呈现:

background: url('data:image/svg+xml;utf8,<svg ...> ... </svg>');

More info on the topic here: https://css-tricks.com/probably-dont-base64-svg/ 有关此主题的更多信息,请访问: https : //css-tricks.com/probably-dont-base64-svg/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM