Description
-
Mixing is an object, and then mixing this object into a certain component
-
The content in data and methods is repeated, and components are used first
-
Life cycle function, first use mixin
-
Can modify priority
-
Define the mixed-in object
const myMixin = {
data(){
return {
a:1
}
}
}
- Use mixed components
data(){
return {
a:2
},
mixins: [myMixin],
- Modify priority
app.config.optionMergeStrategies.number = (mixinVal,appValue) => {
return mixinVal || appValue;
}