0

I need to have attributes including classes and general attributes in root element and extract all native events on child element in a component. According to the new Vue3 documentation there should be some workaround with that since now we have only attrs including everything at once.

I have a simple example of Vue2 code in the template block

<div v-bind="$attrs">
    <button v-on="$listeners">
    </button>
</div>

How do I migrate this to Vue3?

I'm expecting to have attributes on a component's root element and all native events on a child element

  • No straightforward way afaik, you'd need to split context.attrs into two objects yourself based on `^on[A-Z]` regex, the listeners are translated to attrs with "on" prefiix under the hood – Estus Flask Aug 18 '23 at 09:30

0 Answers0