data from mixins not available in component data function
Version
3.1.5 and 3.2.0-beta.8
Reproduction link
Steps to reproduce
See repro link, component should render and display "length (...): 10",
instead there is an error Cannot read property 'length' of undefined
What is expected?
You should be able to access mixin's data from component data function.
What is actually happening?
Mixin's data is not possible to access.
This was tested with 3.0.11 (works), 3.1.5 (not working), and 3.2.0-beta.8 (not working)
I think 3.1.0-beta.6 was the last working version.
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).
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.