Answer the question
In order to leave comments, you need to log in
Recursion + mixins. How to properly organize?
Hello.
There are components:
1. Element - a component in which the template and initial data are described:
/* Element.vue */
<template>
<div class="element__wrap">
<div class="element">
<div v-if="isContainer" class="element__inner">
<NewElement v-for="(item, index) in items" :key="index" :index="index" :type="item.type" :config="item.config" />
</div>
</div>
</div>
</template>
<script>
import Element from "./NewElement.vue"
export default {
name: "Element",
components: {
NewElement
},
data() {
return {
isContainer: false,
};
}
}
</script>
/* ElementContainer.vue */
<script>
export default {
name: "ElementContainer",
data: function () {
return {
isContainer: true,
};
},
}
</script>
/* NewElement.vue */
<script>
import Vue from "vue";
/* Components */
import ElementContainer"./ElementContainer.vue";
import Element from "./Element.vue";
export default Vue.extend({
name: 'NewElement',
mixins: [Element, ElementContainer]
});
</script>
Cannot read property 'components' of undefined
. And if I write in NewElement.vue console.log(Element)
, then I get undefined. Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question