In this example I have an object that got a name
as a string
parameter and a function that just logs this
const me = reactive({
name: "foo",
sayHi: function () {
console.log("Hi I am : ", this);
},
});
In the template I instentiate another component that after 3000ms of it creation emits an event sayHi
. This component is created twice :
<Comp :name="me.name" @sayHi="me.sayHi"/>
<Comp :name="me.name" @sayHi="me.sayHi()"/>
I kind of understand the diffrence between an event handler with and without parentheses explained here but I can't understand why the this
in the first one is undefined
but in the second one its the object itself as I expect.