V
V
vitaly_742021-05-27 16:03:34
Vue.js
vitaly_74, 2021-05-27 16:03:34

How to create a component factory in a Vue component?

The problem is this:
I have a basic model window component.
I want to add this component to expand this component with others. but all of them can be called in a simple way, for example, when I write, I want to call the addNewObjects component, which is inherited through mixins from Modal , and write unique processing actions in this component, for example, sending post via axios when submitting the form. those. the scheme is something like this: ModalComponens-> is AddNewObject -> AddNewObjectsComponent how to do it? went through everything that is possible. while the most adequate option is to call through the tag, which is extremely inconvenient for working with the back.
<modal name="add_new_object"></modal>
<add-new-objects></add-new-objects>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton Anton, 2021-05-27
@Fragster

specifically, what is described is similar to https://ru.vuejs.org/v2/guide/components.html#%D0%...
but in general, usually in the modal window (and this is it, judging by the name of the component) there is a slot, in which the component is placed, which does what it needs.
well, or a higher-order component is made https://habr.com/ru/post/452248/

A
Aetae, 2021-05-27
@Aetae

<template functional>
  <component :is="props.name"/>
</template>

=)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question