[Vuejs]-Vue Directive Reactivity value

0👍

From Vue.js 2 guide:

If you need to share information across hooks, it is recommended to do so through element’s dataset.

So, if I understand correctly your question, you can try in the following way:


Vue.directive('clip', {

    bind: (el, binding) => {

        const clickEventHandler = () => {
            console.log(el.getAttribute('data-clipvalue'))
        }

        el.addEventListener('click', clickEventHandler)
        el.setAttribute('data-clipvalue',binding.value)
        
    },

    update: (el,binding) => {
        el.setAttribute('data-clipvalue',binding.value)
    }

})

Leave a comment