Answer the question
In order to leave comments, you need to log in
How to set a default value for components?
There are two components Tabs and Tab , Tabs acts as a control for a group of several Tabs, it looks like this .
Is it possible to make it so that when the v-model is empty, the first Tab is set by default? I tried to implement this in the setup of the Tab component:
...
setup(props) {
const tabsGroupValue = inject("tabsGroupValue");
const isSelected = computed(() => props.value === tabsGroupValue.value);
if (!tabsGroupValue.value)
tabsGroupValue.value = props.value;
return {
tabsGroupValue,
isSelected,
};
},
...
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question