Reputation: 6974
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 which mixin to use?
Upvotes: 6
Views: 4727
Reputation: 2398
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
Upvotes: 11