Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

data method not called with this as argument when using mixins with data option #7191

Closed
coolzjy opened this issue Dec 6, 2017 · 4 comments
Closed
Labels

Comments

@coolzjy
Copy link
Contributor

@coolzjy coolzjy commented Dec 6, 2017

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

@Akryum
Copy link
Member

@Akryum Akryum commented Dec 6, 2017

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

@Akryum Akryum closed this Dec 6, 2017
@sqal
Copy link
Contributor

@sqal sqal commented Dec 6, 2017

@Akryum Why? Since 2.5 data function receives vm instance as the first argument #6760

@posva posva changed the title data method not called with this as argument when using mixins with data option data method not called with this as argument when using mixins with data option Dec 6, 2017
@posva posva reopened this Dec 6, 2017
@posva posva added the bug label Dec 6, 2017
@Akryum
Copy link
Member

@Akryum Akryum commented Dec 6, 2017

I'm on a PR.

@posva
Copy link
Member

@posva posva commented Dec 6, 2017

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

@Akryum Akryum mentioned this issue Dec 6, 2017
6 of 13 tasks
yyx990803 added a commit that referenced this issue Dec 6, 2017
lovelope added a commit to lovelope/vue that referenced this issue Feb 1, 2018
f2009 pushed a commit to f2009/vue that referenced this issue Jan 25, 2019
erdong-fe pushed a commit to erdong-fe/vue that referenced this issue May 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

4 participants