fix: cannot read properties of undefined offsetWidth

This commit is contained in:
landaiqing
2024-05-05 14:08:12 +08:00
parent 73033b22ab
commit f28e4b0ca7

View File

@@ -17,7 +17,9 @@ const HomeIndex: React.FC = () => {
r: -8,
h: 160,
w: (el: any) => {
return Math.max(320, el.parentNode.offsetWidth * 0.55)
if (el) {
return Math.max(320, el.parentNode.offsetWidth * 0.55)
}
},
},
@@ -29,7 +31,9 @@ const HomeIndex: React.FC = () => {
r: 15,
h: 360,
w: (el: any) => {
return Math.max(220, el.parentNode.offsetWidth * 0.3)
if (el) {
return Math.max(220, el.parentNode.offsetWidth * 0.3)
}
},
},
@@ -41,7 +45,9 @@ const HomeIndex: React.FC = () => {
r: 6,
h: 300,
w: (el: any) => {
return Math.max(330, el.parentNode.offsetWidth * 0.55)
if (el) {
return Math.max(330, el.parentNode.offsetWidth * 0.55)
}
},
},
@@ -53,7 +59,9 @@ const HomeIndex: React.FC = () => {
r: -5,
h: 400,
w: (el: any) => {
return Math.max(305, el.parentNode.offsetWidth * 0.45)
if (el) {
return Math.max(305, el.parentNode.offsetWidth * 0.45)
}
},
},
@@ -65,7 +73,9 @@ const HomeIndex: React.FC = () => {
r: -20,
h: 525,
w: (el: any) => {
return Math.max(160, el.parentNode.offsetWidth * 0.3)
if (el) {
return Math.max(160, el.parentNode.offsetWidth * 0.3)
}
},
},
@@ -77,7 +87,9 @@ const HomeIndex: React.FC = () => {
r: 10,
h: 160,
w: (el: any) => {
return Math.max(320, el.parentNode.offsetWidth * 0.55)
if (el) {
return Math.max(320, el.parentNode.offsetWidth * 0.55)
}
},
},
]