Answer the question
In order to leave comments, you need to log in
How to make dynamic imports?
I have a view form. The form must be used on different sites. They need different inputs.
It is clear that you can add all kinds of inputs to the form and, for example, use
< component :is='нужный инпут в зависимости от пропса'>
, or stupidly several forms in one ifami. import PhoneInput from '@core/inputs/PhoneInput.vue';
export default function (type) {
let CustomInput;
if (type === 'material'){
CustomInput = import('@core/inputs/MaterialInput.vue');
}
else {
CustomInput = import('@core/inputs/BaseInput.vue');
}
return {
components:{
CustomInput,
PhoneInput
}
}
};
Answer the question
In order to leave comments, you need to log in
It is clear that you can add all kinds of inputs to the form and, for example, use
This is how you do it. Register all possible components by making them asynchronous .
You can, for example, make those that can be hooked - global as an option.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question