[Vuejs]-How to omit specific attributes in Vue 3?

1👍

You may transmit all of the attributes from the parent component to a child component in Vue 3 by using the v-bind="$attrs" functionality.

<template>
  <component
    :is="tag"
    :class="twMerge(clsx('font-medium text-base', classAttrs))"
    v-bind="{ ...$attrs, class: undefined }"
  >
    <slot>
      {{ label }}
    </slot>
  </component>
</template>
👤dekts

0👍

Removing useAttrs, and adding :class="twMerge(clsx('text-base font-medium', $attrs.class))" simple solved my issue.

Link: https://vuejs.org/guide/essentials/class-and-style.html#binding-html-classes:~:text=%3C!%2D%2D%20MyComponent%20template%20using%20%24attrs%20%2D%2D%3E

Leave a comment