I have a variety of elements structured like this:
<some-custom-component
:errors="formErrors.has(getErrorKey('town'))"
:error-messages="formErrors.getAll(getErrorKey('town'))"
></some-custom-component>
The formErrors
property and the getErrorKey
function are implemented through a mixin.
I attempted to simplify this div definition by creating a directive. My goal is to achieve something like this:
<some-custom-component v-errorable="'town'"></some-custom-component>
However, I encountered a stumbling block.
// errorable.js
export default {
name: 'errorable',
bind: function (el, binding, vnode) {
// What should be written here to achieve this?
}
}
UPDATE: I believe more context is necessary. The formErrors
is a computed value and getErrorKey
is a method that returns the key to be checked (usually matching the provided parameter such as 'town' -> 'town', etc.)