Answer the question
In order to leave comments, you need to log in
How to register a single-file reusable component?
Good afternoon, dear colleagues.
I create several single-file components to display data, which are included in the root template through
These components are imported into the root component:
<component :is="myComponent"/>
importComponent1 from './components/Component1.vue'
importComponent1 from './components/Component2.vue'
importComponent1 from './components/Component3.vue'
export default {
name: 'App',
store,
components: {
Component1,
Component2,
Component3
},
data () {
myComponent: 'Component1'
}
}
this.$emit('editUser, { id: 1, name: 'John Smith', age: 24 })
<component :is="myComponent" v-on:editUser="createEditUser"/>
createEditUser (userInfo) {
editUser = ... // <- ?
/*
Как динамически создать экземпляр из существующего
однофайлового компонента, который лежит в папке /components
и передать ему userInfo в качестве входных параметров?
*/
this.myComponent = editUser
}
Answer the question
In order to leave comments, you need to log in
All components must be reusable. If your components have a lot of common features, then they can be taken out into an impurity (mixin) or into a service if you are using vue3
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question