Ionic2 - Displaying project images on the UI

梦想与她 提交于 2019-12-29 02:04:08

问题


I have the following brand new project, created with:

$ ionic start MyIonic2Project sidemenu --v2

My question is very simple:

  • 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.

  • 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.


回答1:


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?

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.



来源:https://stackoverflow.com/questions/43625903/ionic2-displaying-project-images-on-the-ui

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!