useVModel(s) should optionally be backwards compatible.
See original GitHub issueClear and concise description of the problem
I would like to create a runtime bridge for v-model to work with Vue 2.X and Vue 3 components. Vue Bridge wants to solve this problem, but is not currently publicized heavily as it is under construction.
I believe VueUse would have better adoption + usage due to its popularity and it already depends on vue-demi.
Is this out of scope?
Suggested solution
In VueUse core, we could extend useVModel to take in an option for backwards compatibility.
As an aside:
I would like Volar + vue-tsc to help create a version of defineProps
and defineEmits
that would support this macro. Is an experimental feature possible @johnsoncodehk? I think I will create an issue in either project (vue-tsc || Volar) regardless of if we end up adding this functionality to VueUse.
Alternative
- We could create a separate function so that useVModel is not weighed down by a heavier API surface area.
- We could decide this is out of scope for VueUse
Additional context
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn’t already an issue that request the same feature to avoid creating a duplicate.
Issue Analytics
- State:
- Created a year ago
- Comments:9 (8 by maintainers)
Top Results From Across the Web
Backward Compatibility Rules - Specmatic
If consumers choose to send the key, the server will now ignore it, which could break consumers assumptions. Optional key becomes mandatory, incompatible ......
Read more >What is Backward Compatible (Backward Compatibility)?
Explore backward compatible hardware and software that can use interfaces and data from earlier versions. Consider examples, pros and cons and the future....
Read more >wsdl - Backward compatible change of a web service API?
To answer your question – it depends. My research over the net tells me that allowing the new optional parameters in response should...
Read more >Q&A: Backward Compatibility for APIs - Embedded Artistry
A rough rule of thumb for maintaining backward compatibility is to never ... If you need to expand a function's parameters, add optional ......
Read more >useVModel - VueUse
import { useVModel } from '@vueuse/core' export default { setup(props, { emit }) { const data = useVModel(props, 'data', emit) console.log(data.value) ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes! It’s almost there, but the open issues block me from using it. Can you double check my usage?
Blockers:
Low-res gif of Vue 2.7 not working with
modelValue
withDefaults
not supportedReproducing:
vite.config.ts
is specific to Vue 2 + Vue 3, with a shared common.Pros:
@JessicaSachs Hi, I already added the support of Vue 2 and the unified prop name. It will transform Vue 3 code to Vue 2 seamless. I also already refactored the code of your project. So just go to check code~ https://github.com/JessicaSachs/petite/compare/v-model-support...sxzz:petite:v-model-support