components文件夹下的helloSlot.vue
<template>
<div>
<h2>{{counter}}</h2>
</div>
</template>
<script>
export default {
name:'helloSlot',
props:{
counter:Number
}
}
</script>
<style>
</style>
APP.vue
<template>
<div id="app">
<h2>{{message}}</h2>
<h2>{{counter}}</h2>
<button @click="counter++">+</button>
<button @click="counter--">-</button>
<hello-slot :counter='counter'></hello-slot>
</div>
</template>
<script>
import helloSlot from './components/helloSlot'
export default {
name:'App',
components:{
helloSlot
},
data(){
return {
message:'我是APP组件',
counter:0
}
}
}
</script>
<style>
</style>