fix: empty img
This commit is contained in:
parent
95be758bcc
commit
72e376a6ad
|
|
@ -32,15 +32,16 @@ customElement("md-bg", {}, (props, { element }) => {
|
||||||
|
|
||||||
const [image] = createResource(resolvedSrc, loadImage);
|
const [image] = createResource(resolvedSrc, loadImage);
|
||||||
|
|
||||||
createEffect(() => {
|
createEffect(() => {
|
||||||
// 图片加载完成后,将背景图片设置到 article 元素
|
// 图片加载完成后,将背景图片设置到 article 元素
|
||||||
console.log(resolvedSrc, image(), articleEl);
|
if(!articleEl)return;
|
||||||
if (image() && articleEl) {
|
articleEl.style.backgroundImage = '';
|
||||||
articleEl.style.backgroundImage = `url(${resolvedSrc})`;
|
if (image()) {
|
||||||
articleEl.style.backgroundSize = 'cover';
|
articleEl.style.backgroundImage = `url(${resolvedSrc})`;
|
||||||
articleEl.style.backgroundPosition = 'center';
|
articleEl.style.backgroundSize = 'cover';
|
||||||
articleEl.style.backgroundRepeat = 'no-repeat';
|
articleEl.style.backgroundPosition = 'center';
|
||||||
}
|
articleEl.style.backgroundRepeat = 'no-repeat';
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue