在Ionic 2中使用图像资产的正确方法 [英] Correct way to use image assets in Ionic 2

查看:80
本文介绍了在Ionic 2中使用图像资产的正确方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Ionic 2中图像资源的最佳做法是什么?我有一堆SVG我想用作非系统图标。我发现了一些关于使用Gulp的旧技巧,但似乎Ionic团队决定将Rollup作为首选的构建工具,到目前为止还没有关于此的文档。

What’s the best practice for image assets in Ionic 2? I have a bunch of SVGs I want to use as non-system icons. I found some older tips on using Gulp but it seems Ionic team has decided on Rollup as the build tool of choice, no docs on this so far.

有人告诉我只需将它们添加到 www / img 。有任何缺点吗?

Somebody told me to just add them to www/img. Any downsides?

推荐答案

将图像放在 www / img 听起来像一个很好的理想,但它只适用于使用 ionic serve 在本地服务。

Placing your images in www/img sounds like a good ideal but it will only work when serving locally using ionic serve.

构建应用程序时, www / img 将被删除,除非您执行gulp任务复制图像从您想要的文件夹到 www / build 文件夹,如图所示在这篇文章中

When building your app, the www/img will get deleted unless you make a gulp task to copy the images from the folder you want to the www/build folder as shown in this post.

html文件中使用的图像应该在 src / assets / img (推荐)而不是 WWW /资产/ IMG (废弃)。图像标签将如下所示:

Images used in html files should be in src/assets/img(recommended) and not www/assets/img(obselete). Image tags would then look like this :

<img src="assets/img/yourimage.jpg" alt="your image">

在离子2中, src / assets 文件夹用于图像和字体。

In ionic 2, the src/assets folder is meant for images and fonts.

这是离子团队在修改现有离子项目的指南



  1. 将www / img移至src / assets / img。

  1. Move www/img to src/assets/img.

移动您在www / to src / assets /.

Move any other resources you have in www/ to src/assets/.


这篇关于在Ionic 2中使用图像资产的正确方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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