Someone knows how inherit a mixin
with its template? or how to inject dinamically elements or components from a mixin
?
EDIT:
After years, I can imagine a elegant solution, and maybe it could be more elegant using classes, typescript or an annotation that create the component super in the mixin, but for now, the problem is partial solved.
GreetingMixin = {
data() {
return {
greeting: 'Hello',
};
},
provide() { return {child: this}},
components: {
super: {
inject: ['child'],
template: '{{ child.greeting }} ',
}
},
}
// This should be Hello World!
Vue.component('welcomeWorld', {
mixins: [GreetingMixin],
template: 'World! ',
});
// This should be Hi ali
Vue.component('welcomeName', {
mixins: [GreetingMixin],
props: ["name"],
created() { this.greeting = "Hi" },
template: '{{ name }} ',
});
// This should be Hello World
Vue.component('welcomeH1', {
mixins: [GreetingMixin],
props: ["name"],
template: '{{ name }}
',
});
var vm = new Vue({
el: '#app'
});
.blue {
color: blue
}