Ionic2 - 在 UI 上显示项目图像 [英] Ionic2 - Displaying project images on the UI

查看:28
本文介绍了Ionic2 - 在 UI 上显示项目图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下全新的项目,创建于:

I have the following brand new project, created with:

$ ionic start MyIonic2Project sidemenu --v2

我的问题很简单:

  • 我在哪里可以找到 应用程序图像(资产图像/固定图像/图标/等)的目录?在:{resources、src、www 等}?我正在寻找最佳实践.

  • where do I locate a directory for application images (asset images / fixed images / icons / etc)?, inside: {resources, src, www, etc}?. I'm looking for best practices.

这些图片的网址会是什么样子?.我想指定 <img src="<url/to/image.jpg>"/> 文件中的元素:src/pages/home/home.ts.

how the url of these images would look like?. I wanna specify the <img src="<url/to/image.jpg>" /> element within the file: src/pages/home/home.ts.

推荐答案

src/assets/ 文件夹应该包含所有资源.您可以根据资源类型使用任何子文件夹.在构建过程中,src/assets 中的所有内容都被复制到 www/assets.

src/assets/ folder should contain all the resources. You can use any sub-folder depending on type of resource. During the build process everything in the src/assets is copied to www/assets.

这些图片的网址会是什么样子?

how the url of these images would look like?

当文件位于 www 文件夹时,您必须提供相对于当前文件的路径.如果您在 scss 文件中进行设置,它通常是 ../assets/../filename.(这最终会成为 build 文件夹中 main.css 的一部分).和 ./assets/../filename 在你的 html 文件中.

You have to give the path relative to your current file when it would be in www folder. It is generally ../assets/../filename if you are setting in your scss file.(This would end up as part of main.css within build folder). and ./assets/../filename in your html file.

这篇关于Ionic2 - 在 UI 上显示项目图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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