Subscribe on changes!

data from mixins not available in component data function

avatar
Aug 9th 2021

Being able to access data from mixins was unintended and undocumented behavior, and was a side effect of Vue 3's different handling of options in 3.0.x.

It was made consistent with Vue 2 in 3.1, so your case is now considered expected behavior (it doesn't work in Vue 2 either).

avatar
Sep 4th 2023

Damn. I stumbled accross the same issue. I would consider the decision a design flaw for a very simple reason: Methods of mixins are available inside the data function, but its data is not. This is inconsistent, and more importantly those methods are very likely themselve to depend on the mixin data. So this means if I am calling a method of the mixin inside the components data function, it might fail because the mixin data is not yet available.

Please reconsider this for both vue2 and vue3, such that both methods and data of mixins will be available, or at least allow those mixin methods to access their own mixin data.