0👍
Your directive needs multiple values a callback function
and data
and may add up in future. Assign your directive to object literal.
<form method="POST" action="api/groups" v-ajax="{successCb: customSuccessFunction, errorCb: customErrFunction, data: data}">
</form>
In your directive you can access them as below
Vue.directive('ajax', function (el, binding) {
console.log(binding.value.successCb.color) // => customSuccessFunction
console.log(binding.value.errorCb.text) // => customErrFunction
console.log(binding.value.data) // => data object
})
- [Vuejs]-Node.js How to upload large user Inputs?
- [Vuejs]-The method works fine but get error in my Vue project
Source:stackexchange.com