I am currently facing an issue where the directive I attach to an element is being executed when the page loads, but I want it to run only when that element is clicked. How can I achieve this functionality?
directives: {
'new-dir': {
bind(el, binding, vnode) {
el.style.cursor = "pointer";
console.log(vnode);
if(vnode.tag == 'div'){
...something }
else if(vnode.tag == 'a') {
console.log("its a link and clicked");
if(vnode.data.attrs.target == "_blank"){
console.log("external link");
} else{
console.log("internal link");
}
} else if(vnode.tag == 'input') {
console.log("its an input ");
console.log("type = " + vnode.data.attrs.type)
console.log("placeholder = " + vnode.data.attrs.placeholder);
}
}
},
}