[Vuejs]-How to make Vue Directive as ES6 class?

0👍

Really late, but maybe this helps: Instead of bind, try inserted.

The documentation

Hook Functions
A directive definition object can provide several hook functions (all optional):

  • bind: called only once, when the directive is first bound to the element. This is where you can do one-time setup work.
  • inserted: called when the bound element has been inserted into its parent node (this only guarantees parent node presence, not necessarily in-document).
  • update: called after the containing component’s VNode has updated, but possibly before its children have updated. The directive’s value may or may not have changed, but you can skip unnecessary updates by comparing the binding’s current and old values (see below on hook arguments).

Leave a comment