diff --git a/src/icon/icon.ts b/src/icon/icon.ts index fda6cd36e..6404b5cd8 100644 --- a/src/icon/icon.ts +++ b/src/icon/icon.ts @@ -41,8 +41,14 @@ export default class Icon extends SuperComponent { this.setData({ isImage }, async () => { if (isImage) { - const { height } = await getRect(this, `.${classPrefix}`); - const iconSize = sizeValue || addUnit(height); + let iconSize = sizeValue; + if (!iconSize) { + await getRect(this, `.${classPrefix}`) + .then((res) => { + iconSize = addUnit(res?.height); + }) + .catch(() => {}); + } iconStyle.width = iconSize; iconStyle.height = iconSize;