Currently, I am working on a Vue 3 single file component that utilizes the script setup method. The challenge I am facing involves defining a prop that should accept values similar to those passed to the HTML class
attribute. This means the prop could be a string, an expression, an array, or an object. However, when attempting to use withDefaults()
to set a default value of an empty string to this prop, issues arise.
withDefaults(
defineProps<{
itemClass?: unknown
}>(),
{
itemClass: '',
}
)
This is then bound as
<div :class="itemClass">...</div>
I am striving to avoid using the type any
, and have experimented with unknown
without success in assigning it a default value. It appears that removing the default value altogether is a temporary workaround, although there may be scenarios where having a default value is essential.
Does anyone know if there exists a specific type tailored for the Vue class
attribute?