8467 shaares
203 private links
203 private links
About 1.
- DOM refs created inside composables need to be explicitly destructured in setup() and returned. Otherwise, they won't be mapped to their DOM element.
Yes... but it is also the point that the template refs must be declared in the vue component. I find it more explicit IHMO. Imagine if multiple components were referencing multiple template refs.... It would add mental burden and forces the developer to know which composable use which refs.
About 2.
- Data inside refs isn't automatically usable by templates unless you wrap the composable invocation with reactive(), which conflicts with point 1 without even more destructuring.
Yes to get the value: const { myRef } = useComposable()
or
const r = reactive(useComposable())