Hello I have this problem with vuejs and mixin. I have a component that has 2 Mixin:
export default {
...
mixins:[Mixin1, Mixin2],
..
}
Both Mixins have a function named "delete", so If in my component I have a method like:
methods:{
deleteObj(){
this.delete()
}
}
I don't know which one function I call. I know the simplest way is call with a different name the functions but is there a way to specify wich mixin to use?
If you duplicated definitions in methods in mixins, the last mixin will override the previous definitions. In your case this.delete()
must called from Mixin2
.
But if have lifecycle hooks like mounted
, created
... those will be executed one by one in vuejs. There are some strategies followed for merging, vuejs itself you can found more at https://v2.vuejs.org/v2/guide/mixins.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With