S
S
Sergey Khlopov2019-08-23 13:28:05
Vue.js
Sergey Khlopov, 2019-08-23 13:28:05

Is it the right decision to apply mixins in the form of adding categories?

Hello, I have a component form-categoryin it there is a form for adding a category and the logic is all there (validation, additional components for the form, etc.) I decided to use this component when editing categories, but I ran into such a problem when the category was successfully added then I clear the form, and when editing, I would not like to clear the form when the category is successfully edited, and most likely I would still encounter a lot of functions that I would not like to perform when editing, so I decided to take the general functionality of editing, adding to mexin (validation and etc.), and after that create a new component for example form-category-updateand use it for editing.
The result is:

  1. form-category- a component adding a category and a mixin with common functionality (validation, etc.) is connected to it
  2. form-category-update- a category editing component and a mixin with common functionality is connected to it...

Well, the mixin itself, which actually connects to form-categoryand to form-category-update.
Can you please tell me if this is the correct solution? It’s just that now I’m thinking that then I will have to edit the markup of the component in two places if I suddenly want to add something, in form-categoryand in form-category-update. Thank you in advance for your response.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question