图像在哪里进入IONIC 2 [英] Where do Images go in IONIC 2
问题描述
我刚刚开始使用Ionic 2.我在 app
中创建了一个 img
文件,里面是一个file logo.png。所以我创建了以下代码:
I am just getting started with Ionic 2. I have created an img
file in app
inside it is a file logo.png. So I have created the following code:
css:
.getting-started {
.logo {
background-image: url(./img/logo.png);
}
}
html:
html:
<ion-col offset-33 width-33 class="logo"><h1>Logo</h1></ion-col>
<h3>Welcome to your first Ionic app!</h3>
</ion-content>
我知道css正在运行,就像我切换背景颜色一样,我得到了预期的结果。但是,我没有获得任何背景图像,只是指定了Logo文本。我应该把图像文件放在哪里?
I know the css is working, as if I toggle the background color, I get the expected results. However, I don't get any background image, just the Logo text specified. Where should I have put the image file?
推荐答案
编辑:从Ionic 2 RC 0开始,放置图像的正确位置在 src / assets / img /
中,引用图像的正确代码是< img src =assets /img/myImg.png\">
。请参阅Ionic的RC0的更改日志(特别是#28)。
EDIT: As of Ionic 2 RC 0, the correct place to put your images is in src/assets/img/
and the correct code to reference the image is <img src="assets/img/myImg.png">
. Please see Ionic's change log for RC0 (specifically #28).
截至目前,使用官方Drifty Co. Ionic 2 会议应用作为参考,图像应放在 www /
目录内。
As of right now, using the official Drifty Co. Ionic 2 Conference App as a reference, images should be placed inside of the www/
directory.
在我目前的Ionic 2应用程序中,图像位于 www / img / logo.png
,并在 app / pages /中引用page_name / page_name.html
as < img src ='img / logo.png'>
,它就像魅力一样。
In my current Ionic 2 app, an image is located at www/img/logo.png
and it is referenced in app/pages/page_name/page_name.html
as <img src='img/logo.png'>
and it works like a charm.
目前使用:
- ionic-angular v2.0.0-beta.6(包。 json)
- ionic-native ^ 1.1.0(package.json)
- ionic-cli v 2.0.0-beta.25(已安装CLI )
这篇关于图像在哪里进入IONIC 2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!