Sagi zawi
Sagi zawi

Reputation: 31

cant access data return{} varibles in VueJS

function HeaderreRender() { 
  HeaderRender = false;
  this.$nextTick(() => {
    HeaderRender = true;
  });
};

export default {
  name: 'Home',
  components: {
    HeaderItem,
  },
  data: function() { 
    return {
      HeaderRender: true,
    };
  }
}

this is the code now I want to use v-if="HeaderRender" to re-render the headerItem but when I call function HeaderreRender() it is replying to me Uncaught ReferenceError: HeaderRender is not defined on the function

any suggestions? on why this happens?

Upvotes: 1

Views: 61

Answers (1)

J2R
J2R

Reputation: 168

Try to place the HeadereRender() function within the methods object of the component and also, it's this.HeaderRender=true

In simple terms, this method does not know about the HeaderRender variable, thus it is not defined in the scope of the function, written that way

Upvotes: 3

Related Questions