Skip to content

How to auto import custom directive in Vue 2? #454

@velmer

Description

@velmer

The title is self-explanatory, is there a way to do this?

src    
│
└───components
│   │   Example.vue
│   
└───directives
    │   color.ts

Example.vue

<template>
  <div v-color="'blue'">Example</div>
</template>

color.ts

export default (el, binding) => {
  el.style.color = binding.value;
};

I also tried with named export: export const color = (el, binding) => ...

I set the directives flag to true and installed Babel, but it didn't work. Is it just missing configuration on my end or there is no way to do this as of now?

PS: I don't know if here is the right place to ask questions, but I couldn't find a more appropriate one. If there is one, please let me know that I will move this question there.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions