bencodezen / vue-enterprise-boilerplate

An ever-evolving, very opinionated architecture and dev environment for new Vue SPA projects using Vue CLI.
7.77k stars 1.32k forks source link

v-bind="$attrs" with Custom Directive #161

Closed ghost closed 4 years ago

ghost commented 5 years ago

Hey,

Actually v-bind="$attrs" and inheritAttrs: false not working with custom directive with custom component that is not a root element. It's normal ? And there is a way to make it work ? Actually i'm making work with a ref. But it's ugly.

// view

<BaseFormPassword v-focus.lazy="true"/>

// BaseFormPassword.vue

// $attrs is empty
<template>
  <div>
    <input
      v-bind="$attrs"
      ...
    />
    ...
  </div>
</template>
chrisvfritz commented 4 years ago

This is difficult, since directives as they're currently implemented in Vue 2 aren't translated into attributes. Your solution using a ref is unfortunately the best solution I know of for now.