v-bind="$attrs" on components requiring some props #2197
Replies: 2 comments 2 replies
-
Does |
Beta Was this translation helpful? Give feedback.
-
Thank you very much for your answer! (sorry for my late follow-up) I do not think is can write TS in the PUG template, so your suggestion gives me some syntax errors (such as But it gave me the idea to try to circumvent it by doing either:
or to following for composition/setup:
And then just use |
Beta Was this translation helpful? Give feedback.
-
When building a wrapper components around another component from an external library (in my case
quasar
), and usingv-bind="$attr"
, I usually get a warning saying that the component I am trying to use is missing a required propsfor example:
Of course, I am passing the
v-model
from the top component call, and everything works in practice, but still I am still seeing this warning.One solution would be to declare a
modelValue
prop in my wrapper Component, and declare it as required, then have a computed property that either reads the props or emitsupdate:model-value
, and use this computed to pass to a newv-model
on the child component; but this is quite verbose. The reason why I would like to usev-bind="$attrs"
is to avoid the boiler-plate code.Maybe I'm asking a bit much, but, is there a known alternative for making components that have
v-bind="$attrs"
assume that all non-explicitly passed props are satisfied, and in the other hand make a wrapper component inherit of the required/typed props from the component on which it is applying av-bind="$attrs"
(This is probably a very difficult feature)?Or, would ignoring the error/warning be preferable for this kind of cases, for now? Sorry for asking this here as well, but is there an easy way to disable
vue-tsc
error in PUG templates, I tried//- @ts-ignore
, but it did not seem to be effective? (I searched a bit around and could not find many examples either)Beta Was this translation helpful? Give feedback.
All reactions