Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change Background of Canvas getting errors #383

Open
AMLUA29 opened this issue May 12, 2024 · 0 comments
Open

Change Background of Canvas getting errors #383

AMLUA29 opened this issue May 12, 2024 · 0 comments

Comments

@AMLUA29
Copy link

AMLUA29 commented May 12, 2024

I am trying to add a background image to Canvas but it hides tools and shows those errors
const canvas = new fabric.Canvas('canvas', { fireRightClick: true, stopContextMenu: true, controlsAboveOverlay: true, imageSmoothingEnabled: false, backgroundImage: 'https://cdn.pixabay.com/photo/2016/03/25/09/04/t-shirt-1278404_960_720.jpg', });

vue-router.js?v=e189ee66:2699 TypeError: instance[methodName] is not a function at klass._toObject (fabric.js?v=e189ee66:7251:46) at klass.callSuper (fabric.js?v=e189ee66:2366:52) at klass._toObject (fabric.js?v=e189ee66:9550:99) at klass._toObject (fabric.js?v=e189ee66:2331:53) at klass.__serializeBgOverlay (fabric.js?v=e189ee66:7277:43) at klass._toObjectMethod (fabric.js?v=e189ee66:7228:31) at klass.toDatalessObject (fabric.js?v=e189ee66:7215:25) at klass.toDatalessJSON (fabric.js?v=e189ee66:7199:25) at fabric.Canvas._historyNext (fabric-history.js?v=e189ee66:11:30) at fabric.Canvas._historyInit (fabric-history.js?v=e189ee66:15:124)

i try to add image to fabric `  fabric.Image.fromURL(
'https://cdn.pixabay.com/photo/2016/03/25/09/04/t-shirt-1278404_960_720.jpg',
function (oImg) {
  oImg.set({
    selectable: false,
    evented: false,
    lockMovementX: true,
    lockMovementY: true,
    lockScalingX: true,
    lockScalingY: true,
    hasControls: false,
    hasBorders: false,
  });
  canvas.add(oImg);
  oImg.viewportCenter();

  canvas.setActiveObject(oImg);
}

);`

but it shows the image in Layer and when press undo it removes the image and I don't want that

What should I do?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant