defineModal default can't use const value
Vue version
3.4.8
Link to minimal reproduction
Steps to reproduce
Reference link
What is expected?
continue as usual
What is actually happening?
error: DEFAULT_VALUE is not defined
System Info
No response
Any additional comments?
No response
This is expected because the options for defineModel
is used as the props options and will be moved outside of setup scope. Similar to the options in defineProps
and defineOptions
.
Note if the constant is a primitive value that can be safely hoisted out, this will work; however, your constant value is an object that may be mutated, so it cannot be hoisted out and therefore cannot be referenced.