Description
Vue version
3.3.4
Link to minimal reproduction
Steps to reproduce
The exposed vue instance when adding a ref to a Vue component in Script Setup differs if you have defined exposes with defineExpose()
.
Create two components, which take a single prop, identical except that one has a defineExpose
.
Import these components in a parent component, and set a ref on them. Then log that ref's value.myProp (in a watcher, or onmounted).
What is expected?
The two logs log the same value.
What is actually happening?
If you do not have a defineExpose
in your component, a parent component can access the props sent to that component via myRef.value.myProp
, but as soon as you define exposes in the component, myRef.value.myProp
returns undefined
.
System Info
No response
Any additional comments?
The documentation for defineExpose
(https://vuejs.org/api/sfc-script-setup.html#defineexpose) doesn't mention anything about that using it change the behaviour of other properties on the ref. So either it seems the documentation is unclear and needs to be clarified, or it is indeed a bug.