我在 global.scss 中尝试过
ion-content{
background-image: url('assets/images/cover.jpg');
-webkit-background-image: url('assets/images/cover.jpg');
background-repeat: no-repeat;
background-size:cover;
}
但这不会渲染图像。也尝试了 ./assets/images/cover.jpg 的路径。
如果我在页面上放置与 img 标签相同的图像,则排除无效图像的可能性。
我还尝试将 homeage.scss 作为
.myview {
background-image: url('../../assets/images/cover.jpg');
background-repeat: no-repeat;
background-size:cover;
}
并在 home.html 中使用 class=“myview” 没有运气
原文由 Vik 发布,翻译遵循 CC BY-SA 4.0 许可协议
您可以使用 CSS-Variable –background 更改 ion-content 的背景。
例子:
将其放入您的组件、页面或全局 scss 中。
参考见: https ://beta.ionicframework.com/docs/api/content#css-custom-properties