一,自己书写组件。
<template>
<div id="app">
<img src="./assets/logo.png">
<router-view/>
</div>
</template>
<script>
export default {
name: '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>
二,在你需要的地方引入
<template>
<div id="app">
<img src="./assets/logo.png">
<router-view/>
<home></home> //3,使用组件
</div>
</template>
<script>
import home from "./pages/home/home.vue" //1 ,引入组件
export default {
name: 'App',
components:{
home,//2,注册组件
},
}
</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>