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