Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ionic4 设备上未显示离子4离子内容背景图像_Ionic4 - Fatal编程技术网

Ionic4 设备上未显示离子4离子内容背景图像

Ionic4 设备上未显示离子4离子内容背景图像,ionic4,Ionic4,我正在尝试在我的ion内容中添加背景图像 这是我目前的代码: 离子含量{ --背景:无; 背景图像:url('/assets/images/home background.png'); 背景位置:中心; 背景重复:无重复; 背景尺寸:封面; 文本对齐:居中; } 我也尝试了以下方法,但同样的事情发生了 离子含量{ --背景:url('/assets/images/home background.png')无重复中心/封面; 文本对齐:居中; } 它在浏览器中工作,但当我在运行android时

我正在尝试在我的ion内容中添加背景图像 这是我目前的代码:

离子含量{ --背景:无; 背景图像:url('/assets/images/home background.png'); 背景位置:中心; 背景重复:无重复; 背景尺寸:封面; 文本对齐:居中; } 我也尝试了以下方法,但同样的事情发生了

离子含量{ --背景:url('/assets/images/home background.png')无重复中心/封面; 文本对齐:居中; } 它在浏览器中工作,但当我在运行android时,背景图像不显示。我还尝试将url更改为
url('../assets/images/home-background.png')
url('./assets/images/home-background.png')
url('../images/home-background.png')

打开scss文件:

ion-content {
    background: url('../../assets/img/myBg.jpg') center bottom no-repeat;
    background-size: 100%; 
}

尝试更改将图像保留在主www/assets/img文件夹中的路径,然后设置

background-image: url('assets/img/home-background.png');
背景图片:url(“…assets/img/home background.png”)


如果您设置了路径,则只需键入../或./自动路径将提示

没有机会使用ionic内容解决此问题,因此我所做的是将ionic内容更改为div,这样就解决了我的问题。在web和android设备中工作。

您可以尝试更改图像url,如下所示

ion-content{
--background: none;
background-image: url('../../assets/images/home-background.png');
background-position: center center;
background-repeat: no-repeat;
background-size: cover;
text-align: center;
}

这对我很有用。

嗨,谢谢你的建议,我可以知道哪一部分可以解决这个问题吗?背景尺寸是否设置为100%?不仅100%,而且没有重复底部。这对我来说很好。我试过了,但还是没有表现出来。我尝试在我的浏览器中调试android设备中的应用程序,它没有给出任何错误,但图像没有显示。很抱歉,回复太晚,在我的android设备上构建应用程序需要时间,但仍然无法工作。我试图复制www/assets/img中的图像并尝试代码,但它给了我一个错误:无法解析“assets/img/home background.png”我尝试在浏览器中运行的代码非常好,但当我尝试运行ionic cordova android时,背景图像没有显示。我甚至尝试过这样做——离子背景颜色:#f04141;,没有错误,但我的ion内容的背景在android设备上是白色的,但在browserhi@Constantine Awa ao工作,你能帮我解决吗?你能和我分享吗?thankshi@thanhdung0312,很抱歉反应太晚,我恐怕这对你没有帮助,但我用div替换了离子内容,我给了div一个id,它是content容器,在scss文件中,我做了一个典型的content容器{background image:url(“myijmage.png”)}