H
H
hannyto11112021-06-29 13:48:42
Vue.js
hannyto1111, 2021-06-29 13:48:42

Why doesn't Vue 3 see the global directive?

Declared in main.js:

import directives from "./extensions-vue/directives";
app.directive(directives);
app.mount("#app");

And in the directive file:

export default {

  widthAsChild: {
    mounted(el, binding) {
      binding.instance.widthAsChild(el);
      window.addEventListener("resize", () => {
        binding.instance.widthAsChild(el);
      });
    },
    updated(el, binding) {
      binding.instance.widthAsChild(el);
    },
  },

};

But vue does not see this directive from the global directives file, if I include it in the component, it works.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2021-06-29
@hannyto1111

app.directive(directives);

What the hell is this? Open the documentation , see what parameters the directive takes.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question