背景报错

This commit is contained in:
李志鹏
2026-01-22 13:17:11 +08:00
parent eaa94edfac
commit 6c921730ef
3 changed files with 13 additions and 10 deletions

View File

@@ -207,7 +207,8 @@ export class BackgroundSizeCommand extends Command {
this.bgLayer = this.layers.value.find((layer) => layer.isBackground);
// 记录原尺寸
this.backgroundObject = findObjectById(this.canvas, this.bgLayer.fabricObject.id).object;
this.bgId = this.bgLayer.fabricObject?.id || this.bgLayer.fabricObjects?.[0]?.id;
this.backgroundObject = findObjectById(this.canvas, this.bgId).object;
this.oldWidth = this.backgroundObject.width;
this.oldHeight = this.backgroundObject.height;