Vue: data method not called with `this` as argument when using mixins with data option

Created on 6 Dec 2017  ·  4Comments  ·  Source: vuejs/vue

Version

2.5.9

Reproduction link

https://codepen.io/cool_zjy/pen/KyLpve

Steps to reproduce

  1. run the reproduction
  2. VueComponent logged in console
  3. uncomment // mixins: [mixin],
  4. run the reproduction again

What is expected?

VueComponent logged in console

What is actually happening?

undefined logged in console

bug

All 4 comments

Please use this to access component instance in hooks and other methods.
https://codepen.io/Akryum/pen/OOYywd

@Akryum Why? Since 2.5 data function receives vm instance as the first argument https://github.com/vuejs/vue/pull/6760

I'm on a PR.

I think the fix is adding this as the second arg on call in the mergeDataOrFn function

Was this page helpful?
0 / 5 - 0 ratings

Related issues

franciscolourenco picture franciscolourenco  ·  3Comments

guan6 picture guan6  ·  3Comments

wufeng87 picture wufeng87  ·  3Comments

julianxhokaxhiu picture julianxhokaxhiu  ·  3Comments

bfis picture bfis  ·  3Comments