vue directive parameter 1

vue directive parameter

Vue.directive('test', { bind(el, binding) { const val = binding.value console.log(val) // hello world } })

Here is what the above code is Doing:
1. We have a directive called test.
2. We have a div with a v-test directive.
3. The v-test directive has a value of ‘hello world’.
4. When the directive is bound to the div, the bind() function is called.
5. The bind() function has access to the value of the directive.
6. We can access the value of the directive by using binding.value.
7. We can then use the value of the directive to do whatever we want.

Similar Posts