[Vuejs]-How to use a plugin's directive in a functional component โ€“ Vue 2

0๐Ÿ‘

โœ…

If you plan to hardcode directive:

const component = createElement('input', {
  directives: [
    name: 'mask',
    value: '##-##-##',
  ]
})

If you just want to pass it down through component, like: <InputBox v-mask="'##-##-##'" />:

const component = createElement('input', {
  ...(data.directives?.length && {
    directives: [data.directives[0]],
  }),
})

It would accept just one directive, if you want to use multiple directives, then you just need to loop through them.

Leave a comment