一 需要混入的配置
export const options = {
beforeCreate() {
console.log('混入的beforeCreate钩子');
},
methods: {
print() {
console.log('混入的print方法');
}
}
};
二 组件
<template>
<div class="app">App组件</div>
</template>
<script>
import { options } from "./mixin.js";
export default {
name: "App",
mixins:[options],
data() {
return {};
}
};
</script>
<style lang="scss" scoped>
.app{
background:gray;
}
</style>
三 结果
本组件中也会含有混入的配置。