G
G
Giftip2021-06-03 00:05:49
Vue.js
Giftip, 2021-06-03 00:05:49

Why are the data fields of the parent component available in the child - when using the debugger?

Hello, my parent component (view) has child components and I am using this. in the child component I can access the data of the parent, why is this happening if I do not use props
For example, in the parent

data() {
    return {
      test: "context",
    };
  },

on the child component
mounted() {
    alert(this.page);
  },

In the debugger, I see the value test
However, when executing undefined
60b7f29f1256c272101173.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Giftip, 2021-06-03
@Giftip

The problem was fixed by using bind(this);

global.context.authorization.$on(
      "authorizationMessage",
      function (msg) {
        this.totalAmount++;
        this.messages.set(this.totalAmount, msg);
      }.bind(this)
    );

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question