当api背景没加载出来显示默认背景图

This commit is contained in:
yeyang
2024-04-04 16:52:43 +08:00
parent 94d8226fc9
commit 82d7ee7175
4 changed files with 7 additions and 1 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

View File

@@ -30,6 +30,7 @@
}
.container {
background-image: url("./img/default_bg.jpg");
background-color: #e9e9e9;
background-position: center top;
background-repeat: no-repeat;

View File

@@ -108,7 +108,11 @@
// 背景api
if (backdrop) {
var container = document.getElementById('container')
container.style.backgroundImage = 'url(' + backdrop + ')'
const img = new Image();
img.onload = function () {
container.style.backgroundImage = 'url(' + backdrop + ')';
}
img.src = backdrop;
}
const by = (value) => {
value = value?.value ?? value

View File

@@ -30,6 +30,7 @@
.container {
background: {
image: url('./img/default_bg.jpg');
color: #e9e9e9;
position: center top;
repeat: no-repeat;