You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The code above works fine, but we need to duplicate the function clearDriverId for the truckId too. That's why we would like to create something like this:
Of course, this does not work because the refdriverId gets unwrapped when passed from the template to the function. What is the correct way to pass a complete ref object to a function?
I am not very sure about this, but AFAIK, you can't get the reference in template without markRaw or some kind of hack. I'd suggest you create functions with the refs in their closure or even make a factory to do that in order to be resued.
exportdefaultdefineComponent({setup(){constdriverId=ref()consttruckId=ref()constclearDriverId=()=>{driverId.value=null}return{//driverId, // it will unwrap selected: {
driverId,// it does not unwrap}}})
For questions please wait a bit longer before opening an issue on github, you can also ask on discord
We're using the Vue Composition API and would like to pass a
ref
object, not just the value, as an argument to a function. Some code to clarify:The code above works fine, but we need to duplicate the function
clearDriverId
for thetruckId
too. That's why we would like to create something like this:Accessed from the template:
Of course, this does not work because the
ref
driverId
gets unwrapped when passed from the template to the function. What is the correct way to pass a completeref
object to a function?We already asked this question on StackOverflow and in the Vue forum.
The text was updated successfully, but these errors were encountered: