前言
我是歌谣 今天给大家带来mixin的讲解
代码案例
<template>
<div id="app">
{{message}}
<HelloWorld msg="data" />
</div>
</template>
<script>
import HelloWorld from "./components/HelloWorld.vue";
const mixin = {
data() {
return {
message: "geyao",
};
},
created(){
console.log("我是mixin")
}
};
export default {
name: "App",
mixins: [mixin],
components: {
HelloWorld,
},
data() {
return {
};
},
created(){
console.log("我是app")
}
};
</script>
<style>
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
</style>