Methods and functions that are used on multiple pages can be written in mixins and reused each time they are used simply by importing the mixin file to the page used. Mixin files are created,mounted… Hook functions, and data and methods are used to declare data and methods to be used on the desired page through mixins attributes
export default {
mixins: [mixin, timeRecord],
components: {},
data(){}}Copy the code
After introduction, the method attributes defined in the mixin file will be copied to the corresponding position of the introduced component, for example, methods will be copied to methods, defined fields will be copied to data, and so on. Each hook function will be matched to the corresponding hook function of the component. It should be noted that the priority order of field/method/hook function defined in mixin file and corresponding method/field/hook function introduced into the component is mainly divided into the following situations: 1. For created, Mounted and other life cycle functions in mixin files, execute the code first, and then perform 2 for components. For fields defined in data, the component defined in the component overrides field 3 of the same name in the mixin. For methods with the same name, methods in the component override methods in mixins