0π
The first argument you get is el
this is the element that the directive is present on.
You can directly use this argument to manipulate the DOM element in your case adding a new CSS class
Vue.directive('editable', {
bind (el, binding, vnode) {
if(condition){
el.className += " " + "hidden";
}
}
})
- [Vuejs]-Vue.js, Router importing template vue file
- [Vuejs]-How to refactor a Vue instance into a working component
Source:stackexchange.com