// Parent componentimportmyMixinfrom'./path';importChildfrom'./ChildPath';exportdefault{mixins:[myMixin],components:{Child}data:()=>({message:'hello from parent component!'})}
// Child Componentexportdefault{created(){this.$parent.sayHello();console.log('hello from child component!')/*
hello from parent component!
hello from child component!
*/}}
Thank you for sharing! I didn't know about that library, but in such cases I'd use the
$parent
property.Example:
suppose you extended more than one mixin. And all the mixin have same method name. Is
$parent
will work?No you can't, but if you control the mixins, isn't it easier to change the name of the methods?
yeah, that's good I know. Thanks
Cool, Thanks for sharing. I was looking for something you did share here.
Btw, it was written by me :p
Yes. I know that :D