0

In my componant, i watch a props name "menu".

I want in this method, get the value of another props name "allowNext".

menu: {
  handler: () => {
    console.log(this.allowNext); !!! FAIL !!!
    console.log(this.props.allowNext); !!! FAIL !!!
    if(this.allowNext){
        // DO SOMETHING
    } 
  },
  deep: true,
},

Vue said : 'props in undefined'. So, when menu changed, i need to check if prop allowNext is true (false by default) to do something.

PS : I don't want if possible add another props for communicate.

Brice Chaponneau
  • 564
  • 2
  • 9
  • 22
  • 1
    Watch handlers are one place where this doesn't appear to be bound as expected. Try using `function() {` instead of the short handed arrow function and see if `this.allowNext` works properly. – Devon Bessemer Jul 16 '18 at 16:37
  • Thanks Devon. No stdob, no duplicate. It's a context, environment – Brice Chaponneau Jul 16 '18 at 17:06

1 Answers1

0

Perfect : don't use anonymous method. Only use handler: function () {}

Brice Chaponneau
  • 564
  • 2
  • 9
  • 22