[Vuejs]-Bind context on vue js method with PIXI JS

2👍

According to the docs:

All methods will have their this context automatically bound to the Vue instance.

You cannot rebind the this context of methods defined on a Vue instance, for the same reason that the following code does not work as expected:

function foo() {
  return this;
}

const X = {};
const Y = {};

const fooX = foo.bind(X);
const fooY = fooX.bind(Y);  // Attempting to bind an already bound function

console.log(fooX() === X);  // true
console.log(fooY() === X);  // true
console.log(fooY() === Y);  // false

You can access the original unbound function through $options:

square
    .on('pointermove', this.$options.methods.onDragMove.bind(square));

Leave a comment