I
I
IsTrueCondition2021-09-15 16:21:36
Vue.js
IsTrueCondition, 2021-09-15 16:21:36

Why doesn't Vue see the variable?

Good afternoon. I can’t understand why I can’t access the variable that is in data: {}

data: function() {
    return {
      default: {
        ...
        hasSelected: false;
        ...
      },
      dirty: {
        ...
        hasSelected: false;
        ...
      },
    }
  }


In the methods, I update the variable in dirty like this: If you display console.log, then everything is OK ... the variable is displayed ... but when rendering html, an error ... In HTML, I access this variable in the v-for loop and gives an error that TypeError: Cannot read property 'hasSelected' of undefined"
Menu.dirty.hasSelected = Boolean(hasSelected);



...
  <div v-if="this.dirty.hasSelected">Lorem</div>
...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2021-09-15
@IsTrueCondition

Templates do not need to specify this

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question