Hey there, I have some elements with the same custom directive but different values in my page.
I want to get all elements with that directive to process on them.
When I use this code:
Vue.directive('can', function (value) {
console.log(value)
})
it just gave me the first element with the can
directive, not all of them, so how I can get all of the elements with the can
directive?!
Update: my elements are like so:
<button v-can="'register-permission'">Register</button>
<button v-can="'buy-permission'">Buy</button>
<button v-can="'Sell-permission'">Sell</button>
I want to access all buttons with the v-can
directive in page! How can it be done?
let cans = []; Vue.directive('can', { inserted: function (el, binding) { cans.push({el: el, value: binding.value}) console.log(JSON.stringify(cans)) } })
– LienBus.$on('permissionChanged', function (data) { let cans = [] Vue.directive('can', function (el, binding, vnode) { cans.push(el) console.log(cans) }) })
– Dafodil