School.vue
<template>
<div class="demo">
<!-- 使用过滤器mySlice匹配字符串 -->
<h2 class="title">学生姓名:{{ name }}</h2>
<h2 class="sex">学生性别:{{ sex }}</h2>
<h2 class="go">123</h2>
</div>
</template>
<script>
export default {
name: "MyStudent",
data() {
return {
name: "疾风剑豪",
sex: "男",
};
},
};
</script>
<style lang="less" scoped>
.demo {
background-color: orange;
.sex {
color: aqua;
}
}
</style>
<style scoped>
.go {
color: brown;
}
</style>
School.vue
<template>
<div class="demo">
<h2 class="title">学校姓名:{{ name }}</h2>
<h2>学生性别:{{ address }}</h2>
</div>
</template>
<script>
export default {
name: "MySchool",
data() {
return {
name: "广职院",
address: "佛山",
};
},
};
</script>
<style scoped>
.demo {
background-color: blue;
margin-top: 100px;
}
</style>
App.vue
<template>
<div>
<school></school>
<student></student>
</div>
</template>
<script>
import Student from "./components/Student.vue";
import School from "./components/School.vue";
export default {
name: "App",
components: {
Student,
School,
},
};
</script>
<style>
.title {
color: red;
}
</style>
main.js
import Vue from 'vue';
import App from './App.vue';
Vue.config.productionTip = false;
new Vue({
render: h => h(App),
}).$mount('#app');