Fabricimage -Klasse mit Fromurl funktioniert nichtJavaScript

Javascript-Forum
Anonymous
 Fabricimage -Klasse mit Fromurl funktioniert nicht

Post by Anonymous »

Code: Select all

import {Component, OnInit} from '@angular/core';
import {Canvas, FabricImage, Image, Rect} from 'fabric';

@Component({
selector: 'app-shirt',
imports: [],
templateUrl: './shirt.component.html',
styleUrl: './shirt.component.scss'
})

export class ShirtComponent implements OnInit {
canvas: Canvas | undefined;

ngOnInit(): void {
this.canvas = new Canvas('canvas', {
width: window.innerWidth,
height: window.innerHeight
});

// Add a rectangle to the canvas
const rectangle = new Rect({
left: 100,
top: 100,
fill: 'blue',
width: 200,
height: 100,
});
this.canvas.add(rectangle);

// Load an external image into the canvas
FabricImage.fromURL('images/custom/shirts/final/1.webp', function (img:any){
var img1 = img.set({
left: 300,
top: 100,
scaleX: 1.5,
scaleY: 1.5,
});
this.canvas.add(img1);
});

this.canvas.renderAll()
}
}
< /code>
Angularversion: 19
fabric.js Version: 6 < /p>
Winkelfehler < /p>
TS2683 : "Dies hat implizit Typ" eine ", weil es keine Typ -Annotation hat. [Plugin Angular-Compiler] < /p>
src/app/custom/products/shirt/shirt.component.ts:38:6:
38 │       this.canvas.add(img1);
╵       ~~~~
< /code>
Ein äußerer Wert von 'this' wird durch diesen Container beschattet. < /p>
src/app/custom/products/shirt/shirt.component.ts:31:61:
31 │ ...e.fromURL('images/custom/shirts/final/1.webp', function (img:any){
Ich verwende auch die Pfeilfunktion in der FromURL, aber das gleiche Problem.
Was ist die tatsächliche Lösung dafür.

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post