I currently have something like this:
<q-input v-model="value" label="Some Label" v-bind="getDefaults('someId')" />
where getDefaults()
is:
function getDefaults (id) {
return {
'id': id,
'clearable': true,
'lazy-rules': true,
'outlined': true,
'class': 'form-padding'
// more props/parameters
}
}
Now, I want to convert the v-bind to a custom directive.
export const sampleDirective = {
inserted: function (el, binding) {
// this doesn't work
el.class += 'form-padding'
// how to set id from here
// and how to set the props as well (like ```clearable```, ```lazy-rules```, etc)?
}
}
So how can I set these parameters/props from the custom directive so I can just call it like this:
<q-input v-model="value" label="Some Label" v-sampleDirective="{ id: 'someId' }" />
Thanks!