uniqueginun's avatar

Best option to refactor several VueJs forms

Hello everyone,

I have like 20 forms all of them have like three in-common fields [description, file upload, title]. the rest of the fields are unique for each form. I am asking what is the best way to build this:

  • use Mixins for the shared fields and use it in every form component
  • build custom form component and then inject the unique fields of each form as slot
  • also I am wondering how the new composition API and composable functions can help me with this
0 likes
3 replies
Sergiu17's avatar

Hey, a dynamic component is the best I guess, something like

<form-input type="text">
<form-input type="email">
<form-input type="password">
<form-input type="file">

in this case you can cover much more,

uniqueginun's avatar

Thanx for your reply @Sergiu17

but when I do that, I think I would still have to define {reactive variables} for these shared fields inside each form component right?

Please or to participate in this conversation.